Commit c377a290 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: add assertions in Browser creation

Adds two assertion to BrowserFragmentImpl.OnCreate.

1. that mBrowser is null, otherwise we're creating a new one. I believe this
   is valid as onCreate() is only called once.
2. that mContext is not-null. My understanding is onCreate() is always called
   after onAttach(), so that mContext should not be null.

BUG=none
TEST=covered by tests

Change-Id: Ic863a8a63406357a867453690be706e55039cb23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2030049Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736901}
parent 6deeb926
...@@ -52,10 +52,12 @@ public class BrowserFragmentImpl extends RemoteFragmentImpl { ...@@ -52,10 +52,12 @@ public class BrowserFragmentImpl extends RemoteFragmentImpl {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
StrictModeWorkaround.apply(); StrictModeWorkaround.apply();
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// onCreate() is only called once
assert mBrowser == null;
mBrowser = new BrowserImpl(mProfile, mPersistenceId, savedInstanceState); mBrowser = new BrowserImpl(mProfile, mPersistenceId, savedInstanceState);
if (mContext != null) { // onCreate() is always called after onAttach(). onAttach() sets |mContext|.
mBrowser.onFragmentAttached(mContext, new FragmentWindowAndroid(mContext, this)); assert mContext != null;
} mBrowser.onFragmentAttached(mContext, new FragmentWindowAndroid(mContext, this));
} }
@Override @Override
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment