blob: b976243d57763010ce1ec32f69d461e8f20e87f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/task_manager/browser_process_resource_provider.h"
#include "base/command_line.h"
#include "base/strings/string16.h"
#include "chrome/browser/task_manager/resource_provider.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/common/content_switches.h"
#include "grit/theme_resources.h"
#include "net/proxy/proxy_resolver_v8.h"
#include "third_party/sqlite/sqlite3.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
namespace task_manager {
namespace {
gfx::ImageSkia* g_default_icon = nullptr;
gfx::ImageSkia* GetDefaultIcon() {
if (!g_default_icon && ResourceBundle::HasSharedInstance()) {
g_default_icon = ResourceBundle::GetSharedInstance().
GetImageSkiaNamed(IDR_PRODUCT_LOGO_16);
if (g_default_icon)
g_default_icon->MakeThreadSafe();
}
return g_default_icon;
}
} // namespace
BrowserProcessResource::BrowserProcessResource()
: title_() {
}
BrowserProcessResource::~BrowserProcessResource() {
}
// Resource methods:
base::string16 BrowserProcessResource::GetTitle() const {
if (title_.empty()) {
title_ = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT);
}
return title_;
}
base::string16 BrowserProcessResource::GetProfileName() const {
return base::string16();
}
gfx::ImageSkia BrowserProcessResource::GetIcon() const {
gfx::ImageSkia* image = GetDefaultIcon();
return image? *image : gfx::ImageSkia();
}
size_t BrowserProcessResource::SqliteMemoryUsedBytes() const {
return static_cast<size_t>(sqlite3_memory_used());
}
base::ProcessHandle BrowserProcessResource::GetProcess() const {
return base::GetCurrentProcessHandle();
}
int BrowserProcessResource::GetUniqueChildProcessId() const {
return 0;
}
Resource::Type BrowserProcessResource::GetType() const {
return BROWSER;
}
bool BrowserProcessResource::SupportNetworkUsage() const {
return true;
}
void BrowserProcessResource::SetSupportNetworkUsage() {
NOTREACHED();
}
bool BrowserProcessResource::ReportsSqliteMemoryUsed() const {
return true;
}
// BrowserProcess uses v8 for proxy resolver in certain cases.
bool BrowserProcessResource::ReportsV8MemoryStats() const {
const base::CommandLine* command_line =
base::CommandLine::ForCurrentProcess();
bool using_v8 = !command_line->HasSwitch(switches::kWinHttpProxyResolver);
if (using_v8 && command_line->HasSwitch(switches::kSingleProcess)) {
using_v8 = false;
}
return using_v8;
}
size_t BrowserProcessResource::GetV8MemoryAllocated() const {
return net::ProxyResolverV8::GetTotalHeapSize();
}
size_t BrowserProcessResource::GetV8MemoryUsed() const {
return net::ProxyResolverV8::GetUsedHeapSize();
}
////////////////////////////////////////////////////////////////////////////////
// BrowserProcessResourceProvider class
////////////////////////////////////////////////////////////////////////////////
BrowserProcessResourceProvider::
BrowserProcessResourceProvider(TaskManager* task_manager)
: updating_(false),
task_manager_(task_manager) {
}
BrowserProcessResourceProvider::~BrowserProcessResourceProvider() {
}
Resource* BrowserProcessResourceProvider::GetResource(
int origin_pid,
int child_id,
int route_id) {
if (origin_pid || child_id != -1) {
return NULL;
}
return &resource_;
}
void BrowserProcessResourceProvider::StartUpdating() {
task_manager_->AddResource(&resource_);
}
void BrowserProcessResourceProvider::StopUpdating() {
}
} // namespace task_manager
|