blob: 72fcd1e9334a6f218f2594258e930e49335ef2fc (
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
// 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/profiler/scoped_tracker.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 "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"
#if defined(OS_MACOSX)
#include "ui/gfx/image/image_skia_util_mac.h"
#endif // defined(OS_MACOSX)
#if defined(OS_WIN)
#include "chrome/browser/app_icon_win.h"
#include "ui/gfx/icon_util.h"
#endif // defined(OS_WIN)
namespace task_manager {
gfx::ImageSkia* BrowserProcessResource::default_icon_ = NULL;
BrowserProcessResource::BrowserProcessResource()
: title_() {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/437890 is fixed.
tracked_objects::ScopedTracker tracking_profile1(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"437890 BrowserProcessResource::BrowserProcessResource1"));
#if defined(OS_WIN)
if (!default_icon_) {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/437890 is fixed.
tracked_objects::ScopedTracker tracking_profile2(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"437890 BrowserProcessResource::BrowserProcessResource2"));
HICON icon = GetAppIcon();
if (icon) {
// TODO(vadimt): Remove ScopedTracker below once crbug.com/437890 is
// fixed.
tracked_objects::ScopedTracker tracking_profile3(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"437890 BrowserProcessResource::BrowserProcessResource3"));
scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon));
default_icon_ = new gfx::ImageSkia(gfx::ImageSkiaRep(*bitmap, 1.0f));
}
}
#elif defined(OS_POSIX)
if (!default_icon_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
default_icon_ = rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_16);
}
#else
// TODO(port): Port icon code.
NOTIMPLEMENTED();
#endif // defined(OS_WIN)
// TODO(vadimt): Remove ScopedTracker below once crbug.com/437890 is
// fixed.
tracked_objects::ScopedTracker tracking_profile4(
FROM_HERE_WITH_EXPLICIT_FUNCTION(
"437890 BrowserProcessResource::BrowserProcessResource4"));
default_icon_->MakeThreadSafe();
}
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 {
return *default_icon_;
}
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
|