New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 725276 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

Update bad cast in Profile::FromBrowserContext

Project Member Reported by creis@chromium.org, May 22 2017

Issue description

As we found in issue 721975, there's a bad cast in the code below, due to TestBrowserContext:

Profile* Profile::FromBrowserContext(content::BrowserContext* browser_context) {
  // This is safe; this is the only implementation of the browser context.
  return static_cast<Profile*>(browser_context);
}

avi@ found that TestBrowserContext was added in r97875 after FromBrowserContext (in r94317).

avi@ or phajdan.jr@, would either of you be able to update this to avoid the bad cast?  Thanks!
 

Comment 1 by a...@chromium.org, May 23 2017

TestBrowserContext is for tests in content and code that isn't in Chrome. For tests in Chrome, like the one found in issue 721975, you need to use TestingProfile in chrome/test/base/testing_profile.h, which actually is a Profile.

I'm not sure of the right way of solving this. We could do (within a DCHECK_IS_ON) use a UserData tag. What do you think about that?

Comment 2 by a...@chromium.org, May 23 2017

BTW, you missed the real bug in issue 721975. Followup on that bug.
Project Member

Comment 3 by bugdroid1@chromium.org, May 31 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/fadbe57adf56100e2f7995ac7c94a9205fbc6aef

commit fadbe57adf56100e2f7995ac7c94a9205fbc6aef
Author: avi <avi@chromium.org>
Date: Wed May 31 20:41:40 2017

Explicitly catch tests in chrome/ not using proper test profiles.

Pretty much all chrome/ code assumes that BrowserContexts are Profiles because those are the BrowserContexts that Chrome instantiates. Explicitly catch test code that violates that assumption.

BUG= 725276 , 721975

Review-Url: https://codereview.chromium.org/2899113002
Cr-Commit-Position: refs/heads/master@{#476007}

[modify] https://crrev.com/fadbe57adf56100e2f7995ac7c94a9205fbc6aef/chrome/browser/profiles/profile.cc

Comment 4 by a...@chromium.org, May 31 2017

Status: Fixed (was: Assigned)

Sign in to add a comment