Do NULL checks on TabAndroids retrieved from the model

There can be TabModels which know about Tabs that are not
alive and cannot yet be instantiated.  Do NULL checks before
checking the Tabs.

BUG=403592
R=dgozman@chromium.org, dtrainor@chromium.org

Review URL: https://codereview.chromium.org/542953002

Cr-Commit-Position: refs/heads/master@{#293574}
parent c54cc7cb
......@@ -188,6 +188,9 @@ class TabTarget : public TargetBase {
if (!web_contents) {
// The tab has been pushed out of memory, pull it back.
TabAndroid* tab = model->GetTabAt(index);
if (!tab)
return NULL;
tab->LoadIfNeeded();
web_contents = model->GetWebContentsAt(index);
if (!web_contents)
......@@ -231,7 +234,7 @@ class TabTarget : public TargetBase {
TabModel* model = *iter;
for (int i = 0; i < model->GetTabCount(); ++i) {
TabAndroid* tab = model->GetTabAt(i);
if (tab->GetAndroidId() == tab_id_) {
if (tab && tab->GetAndroidId() == tab_id_) {
*model_result = model;
*index_result = i;
return true;
......@@ -363,6 +366,9 @@ class DevToolsServerDelegate : public content::DevToolsHttpHandlerDelegate {
TabModel* model = *iter;
for (int i = 0; i < model->GetTabCount(); ++i) {
TabAndroid* tab = model->GetTabAt(i);
if (!tab)
continue;
WebContents* web_contents = model->GetWebContentsAt(i);
if (web_contents) {
tab_web_contents.insert(web_contents);
......
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