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

Side by Side Diff: chrome/browser/task_management/providers/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: Converting size_t's to int64's 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_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* g_default_icon = nullptr;
30
31 gfx::ImageSkia* GetDefaultIcon() {
32 if (!g_default_icon) {
33 #if defined(OS_WIN)
34 HICON icon = GetAppIcon();
35 if (icon) {
36 scoped_ptr<SkBitmap> bitmap(IconUtil::CreateSkBitmapFromHICON(icon));
37 g_default_icon = new gfx::ImageSkia(gfx::ImageSkiaRep(*bitmap, 1.0f));
38 }
39 #elif defined(OS_POSIX)
40 if (ResourceBundle::HasSharedInstance()) {
41 g_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 (g_default_icon)
49 g_default_icon->MakeThreadSafe();
50 }
51
52 return g_default_icon;
53 }
54
55 bool ReportsV8Stats() {
56 const base::CommandLine* command_line =
57 base::CommandLine::ForCurrentProcess();
58 return !command_line->HasSwitch(switches::kWinHttpProxyResolver) &&
59 !command_line->HasSwitch(switches::kSingleProcess);
60 }
61
62 } // namespace
63
64 BrowserProcessTask::BrowserProcessTask()
65 : Task(l10n_util::GetStringUTF16(IDS_TASK_MANAGER_WEB_BROWSER_CELL_TEXT),
66 *GetDefaultIcon(),
67 base::GetCurrentProcessHandle()),
68 allocated_v8_memory_(-1),
69 used_v8_memory_(-1),
70 used_sqlite_memory_(-1),
71 reports_v8_stats_(ReportsV8Stats()){
72 }
73
74 BrowserProcessTask::~BrowserProcessTask() {
75 }
76
77 void BrowserProcessTask::Refresh(const base::TimeDelta& update_interval) {
78 Task::Refresh(update_interval);
79
80 // TODO(afakhry): Add code to skip v8 and sqlite stats update if they have
81 // never been requested.
82 if (reports_v8_stats_) {
83 allocated_v8_memory_ =
84 static_cast<int64>(net::ProxyResolverV8::GetTotalHeapSize());
85 used_v8_memory_ =
86 static_cast<int64>(net::ProxyResolverV8::GetUsedHeapSize());
87 }
88
89 used_sqlite_memory_ = static_cast<int64>(sqlite3_memory_used());
90 }
91
92 Task::Type BrowserProcessTask::GetType() const {
93 return Task::BROWSER;
94 }
95
96 int BrowserProcessTask::GetChildProcessUniqueID() const {
97 return 0;
98 }
99
100 int64 BrowserProcessTask::GetSqliteMemoryUsed() const {
101 return used_sqlite_memory_;
102 }
103
104 int64 BrowserProcessTask::GetV8MemoryAllocated() const {
105 return allocated_v8_memory_;
106 }
107
108 int64 BrowserProcessTask::GetV8MemoryUsed() const {
109 return used_v8_memory_;
110 }
111
112 } // namespace task_management
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698