Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/task_manager/providers/web_contents/extension_task.cc

Issue 2653563003: Add a "Keepalive count" column to Task Manager. (Closed)
Patch Set: Address review comment re description Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/task_manager/providers/web_contents/extension_task.h" 5 #include "chrome/browser/task_manager/providers/web_contents/extension_task.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 } // namespace 41 } // namespace
42 42
43 ExtensionTask::ExtensionTask(content::WebContents* web_contents, 43 ExtensionTask::ExtensionTask(content::WebContents* web_contents,
44 const extensions::Extension* extension, 44 const extensions::Extension* extension,
45 extensions::ViewType view_type) 45 extensions::ViewType view_type)
46 : RendererTask(GetExtensionTitle(web_contents, extension, view_type), 46 : RendererTask(GetExtensionTitle(web_contents, extension, view_type),
47 GetDefaultIcon(), 47 GetDefaultIcon(),
48 web_contents, 48 web_contents,
49 web_contents->GetRenderProcessHost()) { 49 web_contents->GetRenderProcessHost()),
50 view_type_(view_type) {
50 LoadExtensionIcon(extension); 51 LoadExtensionIcon(extension);
51 } 52 }
52 53
53 ExtensionTask::~ExtensionTask() { 54 ExtensionTask::~ExtensionTask() {
54 } 55 }
55 56
56 void ExtensionTask::UpdateTitle() { 57 void ExtensionTask::UpdateTitle() {
57 // The title of the extension should not change as a result of title change 58 // The title of the extension should not change as a result of title change
58 // in its WebContents, so we ignore this. 59 // in its WebContents, so we ignore this.
59 } 60 }
(...skipping 26 matching lines...) Expand all
86 if (!browser) 87 if (!browser)
87 return; 88 return;
88 89
89 chrome::ShowExtensions(browser, extension->id()); 90 chrome::ShowExtensions(browser, extension->id());
90 } 91 }
91 92
92 Task::Type ExtensionTask::GetType() const { 93 Task::Type ExtensionTask::GetType() const {
93 return Task::EXTENSION; 94 return Task::EXTENSION;
94 } 95 }
95 96
97 int ExtensionTask::GetKeepaliveCount() const {
98 if (view_type_ != extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE)
99 return -1;
100
101 const extensions::Extension* extension =
102 extensions::ProcessManager::Get(web_contents()->GetBrowserContext())
103 ->GetExtensionForWebContents(web_contents());
104 if (!extension)
105 return -1;
106
107 return extensions::ProcessManager::Get(web_contents()->GetBrowserContext())
108 ->GetLazyKeepaliveCount(extension);
109 }
110
96 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) { 111 void ExtensionTask::OnExtensionIconImageChanged(extensions::IconImage* image) {
97 DCHECK_EQ(extension_icon_.get(), image); 112 DCHECK_EQ(extension_icon_.get(), image);
98 113
99 if (!image->image_skia().isNull()) 114 if (!image->image_skia().isNull())
100 set_icon(image->image_skia()); 115 set_icon(image->image_skia());
101 } 116 }
102 117
103 base::string16 ExtensionTask::GetExtensionTitle( 118 base::string16 ExtensionTask::GetExtensionTitle(
104 content::WebContents* web_contents, 119 content::WebContents* web_contents,
105 const extensions::Extension* extension, 120 const extensions::Extension* extension,
(...skipping 26 matching lines...) Expand all
132 extension_misc::EXTENSION_ICON_SMALL, 147 extension_misc::EXTENSION_ICON_SMALL,
133 icon(), 148 icon(),
134 this)); 149 this));
135 150
136 // Triggers actual image loading with 1x resources. 151 // Triggers actual image loading with 1x resources.
137 extension_icon_->image_skia().GetRepresentation(1.0f); 152 extension_icon_->image_skia().GetRepresentation(1.0f);
138 set_icon(extension_icon_->image_skia()); 153 set_icon(extension_icon_->image_skia());
139 } 154 }
140 155
141 } // namespace task_manager 156 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698