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
3 // found in the LICENSE file.
5 #include "chrome/browser/task_management/providers/browser_process_task.h"
7 #include "base/command_line.h"
8 #include "chrome/browser/task_management/task_manager_observer.h"
9 #include "chrome/common/chrome_switches.h"
10 #include "chrome/grit/generated_resources.h"
11 #include "grit/theme_resources.h"
12 #include "net/proxy/proxy_resolver_v8.h"
13 #include "third_party/sqlite/sqlite3.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h"
17 namespace task_management
{
21 gfx::ImageSkia
* g_default_icon
= nullptr;
23 gfx::ImageSkia
* GetDefaultIcon() {
24 if (!g_default_icon
&& ResourceBundle::HasSharedInstance()) {
25 g_default_icon
= ResourceBundle::GetSharedInstance().
26 GetImageSkiaNamed(IDR_PRODUCT_LOGO_16
);
28 g_default_icon
->MakeThreadSafe();
31 return g_default_icon
;
34 bool ReportsV8Stats() {
35 const base::CommandLine
* command_line
=
36 base::CommandLine::ForCurrentProcess();
37 return !command_line
->HasSwitch(switches::kWinHttpProxyResolver
) &&
38 !command_line
->HasSwitch(switches::kSingleProcess
);
43 BrowserProcessTask::BrowserProcessTask()
44 : Task(l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT
),
46 base::GetCurrentProcessHandle()),
47 allocated_v8_memory_(-1),
49 used_sqlite_memory_(-1),
50 reports_v8_stats_(ReportsV8Stats()){
53 BrowserProcessTask::~BrowserProcessTask() {
56 void BrowserProcessTask::Refresh(const base::TimeDelta
& update_interval
,
57 int64 refresh_flags
) {
58 Task::Refresh(update_interval
, refresh_flags
);
60 if (reports_v8_stats_
&& (refresh_flags
& REFRESH_TYPE_V8_MEMORY
) != 0) {
61 allocated_v8_memory_
=
62 static_cast<int64
>(net::ProxyResolverV8::GetTotalHeapSize());
64 static_cast<int64
>(net::ProxyResolverV8::GetUsedHeapSize());
67 if ((refresh_flags
& REFRESH_TYPE_SQLITE_MEMORY
) != 0)
68 used_sqlite_memory_
= static_cast<int64
>(sqlite3_memory_used());
71 Task::Type
BrowserProcessTask::GetType() const {
75 int BrowserProcessTask::GetChildProcessUniqueID() const {
79 int64
BrowserProcessTask::GetSqliteMemoryUsed() const {
80 return used_sqlite_memory_
;
83 int64
BrowserProcessTask::GetV8MemoryAllocated() const {
84 return allocated_v8_memory_
;
87 int64
BrowserProcessTask::GetV8MemoryUsed() const {
88 return used_v8_memory_
;
91 } // namespace task_management