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

Side by Side Diff: chrome/browser/task_management/providers/browser_process/browser_process_task.cc

Issue 1038033002: New Task Manager - Phase 1.1: Implement Browser Process Task Providing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: As agreed, made network_usage_ calculation accurate. Created 5 years, 8 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
(Empty)
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.
4
5 #include "chrome/browser/task_management/providers/browser_process/browser_proce ss_task.h"
6
7 #include "base/command_line.h"
8 #include "chrome/common/chrome_switches.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "grit/theme_resources.h"
11 #include "net/proxy/proxy_resolver_v8.h"
12 #include "third_party/sqlite/sqlite3.h"
13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h"
15
16 #if defined(OS_MACOSX)
17 #include "ui/gfx/image/image_skia_util_mac.h"
18 #endif // defined(OS_MACOSX)
19
20 #if defined(OS_WIN)
21 #include "chrome/browser/app_icon_win.h"
22 #include "ui/gfx/icon_util.h"
23 #endif // defined(OS_WIN)
24
25 namespace task_management {
26
27 namespace {
28
29 gfx::ImageSkia* default_icon = nullptr;
Lei Zhang 2015/04/01 22:47:50 nit: |g_default_icon|
afakhry 2015/04/03 01:51:00 Done.
30
31 gfx::ImageSkia* GetDefaultIcon() {
32 if (!default_icon) {
33 #if defined(OS_WIN)
34 HICON icon = GetAppIcon();
35 if (icon) {
36 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon));
37 default_icon_ = new gfx::ImageSkia(gfx::ImageSkiaRep(*bitmap, 1.0f));
38 }
39 #elif defined(OS_POSIX)
40 if (ResourceBundle::HasSharedInstance()) {
41 default_icon = ResourceBundle::GetSharedInstance().
42 GetImageSkiaNamed(IDR_PRODUCT_LOGO_16);
43 }
44 #else
45 // TODO(port): Port icon code.
46 NOTIMPLEMENTED();
47 #endif // defined(OS_WIN)
48 if (default_icon)
49 default_icon->MakeThreadSafe();
50 }
51
52 return default_icon;
53 }
54
55 bool ReportsV8Stats() {
56 const base::CommandLine* command_line =
57 base::CommandLine::ForCurrentProcess();
58 return command_line &&
Lei Zhang 2015/04/01 22:47:50 I don't think anyone checks the ForCurrentProcess(
afakhry 2015/04/03 01:51:00 Done.
59 !command_line->HasSwitch(switches::kWinHttpProxyResolver) &&
60 !command_line->HasSwitch(switches::kSingleProcess);
61 }
62
63 } // namespace
64
65 BrowserProcessTask::BrowserProcessTask()
66 : Task(l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT),
67 *GetDefaultIcon(),
68 base::GetCurrentProcessHandle()),
69 allocated_v8_memory_(-1U),
70 used_v8_memory_(-1U),
71 used_sqlite_memory_(-1U),
72 reports_v8_stats_(ReportsV8Stats()){
73 }
74
75 BrowserProcessTask::~BrowserProcessTask() {
76 }
77
78 Task::Type BrowserProcessTask::GetType() const {
79 return Task::BROWSER;
80 }
81
82 int BrowserProcessTask::GetChildProcessUniqueID() const {
83 return 0;
84 }
85
86 size_t BrowserProcessTask::GetSqliteMemoryUsed() const {
87 return used_sqlite_memory_;
88 }
89
90 size_t BrowserProcessTask::GetV8MemoryAllocated() const {
91 return allocated_v8_memory_;
92 }
93
94 size_t BrowserProcessTask::GetV8MemoryUsed() const {
95 return used_v8_memory_;
96 }
97
98 void BrowserProcessTask::Refresh(const base::TimeDelta& update_interval) {
99 Task::Refresh(update_interval);
100
101 // TODO(afakhry): Add code to skip v8 and sqlite stats update if they have
102 // never been requested.
103 if (reports_v8_stats_) {
104 allocated_v8_memory_ = net::ProxyResolverV8::GetTotalHeapSize();
105 used_v8_memory_ = net::ProxyResolverV8::GetUsedHeapSize();
106 }
107
108 used_sqlite_memory_ = static_cast<size_t>(sqlite3_memory_used());
Lei Zhang 2015/04/01 22:47:50 I don't see sqlite3_memory_used() implemented anyw
afakhry 2015/04/03 01:51:00 It's implemented in 'src/third_party/sqlite/amalga
109 }
110
111 } // namespace task_management
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698