Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / task_manager / browser_process_resource_provider.cc
blob41fc65b2d265fb13ff15a31764e926763d16d3ea
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/task_manager/browser_process_resource_provider.h"
7 #include "base/command_line.h"
8 #include "base/strings/string16.h"
9 #include "chrome/browser/task_manager/resource_provider.h"
10 #include "chrome/browser/task_manager/task_manager.h"
11 #include "chrome/common/chrome_switches.h"
12 #include "chrome/grit/generated_resources.h"
13 #include "grit/theme_resources.h"
14 #include "net/proxy/proxy_resolver_v8.h"
15 #include "third_party/sqlite/sqlite3.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gfx/image/image_skia.h"
20 namespace task_manager {
22 namespace {
24 gfx::ImageSkia* g_default_icon = nullptr;
26 gfx::ImageSkia* GetDefaultIcon() {
27 if (!g_default_icon && ResourceBundle::HasSharedInstance()) {
28 g_default_icon = ResourceBundle::GetSharedInstance().
29 GetImageSkiaNamed(IDR_PRODUCT_LOGO_16);
30 if (g_default_icon)
31 g_default_icon->MakeThreadSafe();
34 return g_default_icon;
37 } // namespace
39 BrowserProcessResource::BrowserProcessResource()
40 : title_() {
43 BrowserProcessResource::~BrowserProcessResource() {
46 // Resource methods:
47 base::string16 BrowserProcessResource::GetTitle() const {
48 if (title_.empty()) {
49 title_ = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT);
51 return title_;
54 base::string16 BrowserProcessResource::GetProfileName() const {
55 return base::string16();
58 gfx::ImageSkia BrowserProcessResource::GetIcon() const {
59 gfx::ImageSkia* image = GetDefaultIcon();
60 return image? *image : gfx::ImageSkia();
63 size_t BrowserProcessResource::SqliteMemoryUsedBytes() const {
64 return static_cast<size_t>(sqlite3_memory_used());
67 base::ProcessHandle BrowserProcessResource::GetProcess() const {
68 return base::GetCurrentProcessHandle();
71 int BrowserProcessResource::GetUniqueChildProcessId() const {
72 return 0;
75 Resource::Type BrowserProcessResource::GetType() const {
76 return BROWSER;
79 bool BrowserProcessResource::SupportNetworkUsage() const {
80 return true;
83 void BrowserProcessResource::SetSupportNetworkUsage() {
84 NOTREACHED();
87 bool BrowserProcessResource::ReportsSqliteMemoryUsed() const {
88 return true;
91 // BrowserProcess uses v8 for proxy resolver in certain cases.
92 bool BrowserProcessResource::ReportsV8MemoryStats() const {
93 const base::CommandLine* command_line =
94 base::CommandLine::ForCurrentProcess();
95 bool using_v8 = !command_line->HasSwitch(switches::kWinHttpProxyResolver);
96 if (using_v8 && command_line->HasSwitch(switches::kSingleProcess)) {
97 using_v8 = false;
99 return using_v8;
102 size_t BrowserProcessResource::GetV8MemoryAllocated() const {
103 return net::ProxyResolverV8::GetTotalHeapSize();
106 size_t BrowserProcessResource::GetV8MemoryUsed() const {
107 return net::ProxyResolverV8::GetUsedHeapSize();
110 ////////////////////////////////////////////////////////////////////////////////
111 // BrowserProcessResourceProvider class
112 ////////////////////////////////////////////////////////////////////////////////
114 BrowserProcessResourceProvider::
115 BrowserProcessResourceProvider(TaskManager* task_manager)
116 : updating_(false),
117 task_manager_(task_manager) {
120 BrowserProcessResourceProvider::~BrowserProcessResourceProvider() {
123 Resource* BrowserProcessResourceProvider::GetResource(
124 int origin_pid,
125 int child_id,
126 int route_id) {
127 if (origin_pid || child_id != -1) {
128 return NULL;
131 return &resource_;
134 void BrowserProcessResourceProvider::StartUpdating() {
135 task_manager_->AddResource(&resource_);
138 void BrowserProcessResourceProvider::StopUpdating() {
141 } // namespace task_manager