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

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: Addressing Nick's comments 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;
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 &&
59 !command_line->HasSwitch(switches::kWinHttpProxyResolver) &&
60 !command_line->HasSwitch(switches::kSingleProcess);
61 }
62
63 } // namespace
64
65 // ----------------------------------------------------------------------
66 // Public Members:
67 // ----------------------------------------------------------------------
ncarter (slow) 2015/03/31 19:04:24 I showed this .cc file to two top-level content/ o
68
69 BrowserProcessTask::BrowserProcessTask()
70 : Task(l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT),
71 *GetDefaultIcon(),
72 base::GetCurrentProcessHandle()),
73 allocated_v8_memory_(-1U),
74 used_v8_memory_(-1U),
75 used_sqlite_memory_(-1U),
76 reports_v8_stats_(ReportsV8Stats()){
77 }
78
79 BrowserProcessTask::~BrowserProcessTask() {
80 }
81
82 // ----------------------------------------------------------------------
83 // Private Members:
84 // ----------------------------------------------------------------------
85
86 Task::Type BrowserProcessTask::GetType() const {
87 return Task::BROWSER;
88 }
89
90 int BrowserProcessTask::GetChildProcessUniqueID() const {
91 return 0;
92 }
93
94 size_t BrowserProcessTask::GetSqliteMemoryUsed() const {
95 return used_sqlite_memory_;
96 }
97
98 size_t BrowserProcessTask::GetV8MemoryAllocated() const {
99 return allocated_v8_memory_;
100 }
101
102 size_t BrowserProcessTask::GetV8MemoryUsed() const {
103 return used_v8_memory_;
104 }
105
106 void BrowserProcessTask::Refresh(const base::TimeDelta& update_time) {
107 Task::Refresh(update_time);
108
109 // TODO(afakhry): Add code to skip v8 and sqlite stats update if they have
110 // never been requested.
111 if (reports_v8_stats_) {
112 allocated_v8_memory_ = net::ProxyResolverV8::GetTotalHeapSize();
113 used_v8_memory_ = net::ProxyResolverV8::GetUsedHeapSize();
114 }
115
116 used_sqlite_memory_ = static_cast<size_t>(sqlite3_memory_used());
117 }
118
119 } // namespace task_management
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698