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

Side by Side Diff: chrome/browser/task_manager/task_manager_worker_resource_provider.cc

Issue 10453101: Convert most of the rest of chrome to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h" 5 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/debugger/devtools_window.h" 12 #include "chrome/browser/debugger/devtools_window.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/child_process_data.h" 15 #include "content/public/browser/child_process_data.h"
16 #include "content/public/browser/devtools_agent_host_registry.h" 16 #include "content/public/browser/devtools_agent_host_registry.h"
17 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/worker_service.h" 19 #include "content/public/browser/worker_service.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "grit/theme_resources_standard.h" 21 #include "grit/theme_resources_standard.h"
22 #include "third_party/skia/include/core/SkBitmap.h"
23 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/gfx/image/image_skia.h"
25 25
26 using content::BrowserThread; 26 using content::BrowserThread;
27 using content::DevToolsAgentHost; 27 using content::DevToolsAgentHost;
28 using content::DevToolsAgentHostRegistry; 28 using content::DevToolsAgentHostRegistry;
29 using content::WorkerService; 29 using content::WorkerService;
30 30
31 // Objects of this class are created on the IO thread and then passed to the UI 31 // Objects of this class are created on the IO thread and then passed to the UI
32 // thread where they are passed to the task manager. All methods must be called 32 // thread where they are passed to the task manager. All methods must be called
33 // only on the UI thread. Destructor may be called on any thread. 33 // only on the UI thread. Destructor may be called on any thread.
34 class TaskManagerSharedWorkerResource : public TaskManager::Resource { 34 class TaskManagerSharedWorkerResource : public TaskManager::Resource {
35 public: 35 public:
36 TaskManagerSharedWorkerResource(const GURL& url, 36 TaskManagerSharedWorkerResource(const GURL& url,
37 const string16& name, 37 const string16& name,
38 int process_id, 38 int process_id,
39 int routing_id, 39 int routing_id,
40 base::ProcessHandle process_handle); 40 base::ProcessHandle process_handle);
41 virtual ~TaskManagerSharedWorkerResource(); 41 virtual ~TaskManagerSharedWorkerResource();
42 42
43 bool Matches(int process_id, int routing_id) const; 43 bool Matches(int process_id, int routing_id) const;
44 44
45 void UpdateProcessHandle(base::ProcessHandle handle); 45 void UpdateProcessHandle(base::ProcessHandle handle);
46 base::ProcessHandle handle() const { return handle_; } 46 base::ProcessHandle handle() const { return handle_; }
47 int process_id() const { return process_id_; } 47 int process_id() const { return process_id_; }
48 48
49 private: 49 private:
50 // TaskManager::Resource methods: 50 // TaskManager::Resource methods:
51 virtual string16 GetTitle() const OVERRIDE; 51 virtual string16 GetTitle() const OVERRIDE;
52 virtual string16 GetProfileName() const OVERRIDE; 52 virtual string16 GetProfileName() const OVERRIDE;
53 virtual SkBitmap GetIcon() const OVERRIDE; 53 virtual gfx::ImageSkia GetIcon() const OVERRIDE;
54 virtual base::ProcessHandle GetProcess() const OVERRIDE; 54 virtual base::ProcessHandle GetProcess() const OVERRIDE;
55 virtual int GetUniqueChildProcessId() const OVERRIDE; 55 virtual int GetUniqueChildProcessId() const OVERRIDE;
56 virtual Type GetType() const OVERRIDE; 56 virtual Type GetType() const OVERRIDE;
57 virtual bool CanInspect() const OVERRIDE; 57 virtual bool CanInspect() const OVERRIDE;
58 virtual void Inspect() const OVERRIDE; 58 virtual void Inspect() const OVERRIDE;
59 59
60 virtual bool SupportNetworkUsage() const OVERRIDE; 60 virtual bool SupportNetworkUsage() const OVERRIDE;
61 virtual void SetSupportNetworkUsage() OVERRIDE; 61 virtual void SetSupportNetworkUsage() OVERRIDE;
62 62
63 int process_id_; 63 int process_id_;
64 int routing_id_; 64 int routing_id_;
65 string16 title_; 65 string16 title_;
66 base::ProcessHandle handle_; 66 base::ProcessHandle handle_;
67 67
68 static SkBitmap* default_icon_; 68 static gfx::ImageSkia* default_icon_;
69 69
70 DISALLOW_COPY_AND_ASSIGN(TaskManagerSharedWorkerResource); 70 DISALLOW_COPY_AND_ASSIGN(TaskManagerSharedWorkerResource);
71 }; 71 };
72 72
73 SkBitmap* TaskManagerSharedWorkerResource::default_icon_ = NULL; 73 gfx::ImageSkia* TaskManagerSharedWorkerResource::default_icon_ = NULL;
74 74
75 TaskManagerSharedWorkerResource::TaskManagerSharedWorkerResource( 75 TaskManagerSharedWorkerResource::TaskManagerSharedWorkerResource(
76 const GURL& url, 76 const GURL& url,
77 const string16& name, 77 const string16& name,
78 int process_id, 78 int process_id,
79 int routing_id, 79 int routing_id,
80 base::ProcessHandle process_handle) 80 base::ProcessHandle process_handle)
81 : process_id_(process_id), 81 : process_id_(process_id),
82 routing_id_(routing_id), 82 routing_id_(routing_id),
83 handle_(process_handle) { 83 handle_(process_handle) {
(...skipping 16 matching lines...) Expand all
100 } 100 }
101 101
102 string16 TaskManagerSharedWorkerResource::GetTitle() const { 102 string16 TaskManagerSharedWorkerResource::GetTitle() const {
103 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title_); 103 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_WORKER_PREFIX, title_);
104 } 104 }
105 105
106 string16 TaskManagerSharedWorkerResource::GetProfileName() const { 106 string16 TaskManagerSharedWorkerResource::GetProfileName() const {
107 return string16(); 107 return string16();
108 } 108 }
109 109
110 SkBitmap TaskManagerSharedWorkerResource::GetIcon() const { 110 gfx::ImageSkia TaskManagerSharedWorkerResource::GetIcon() const {
111 if (!default_icon_) { 111 if (!default_icon_) {
112 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 112 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
113 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); 113 default_icon_ = rb.GetImageSkiaNamed(IDR_PLUGIN);
114 // TODO(jabdelmalek): use different icon for web workers. 114 // TODO(jabdelmalek): use different icon for web workers.
115 } 115 }
116 return *default_icon_; 116 return *default_icon_;
117 } 117 }
118 118
119 base::ProcessHandle TaskManagerSharedWorkerResource::GetProcess() const { 119 base::ProcessHandle TaskManagerSharedWorkerResource::GetProcess() const {
120 return handle_; 120 return handle_;
121 } 121 }
122 122
123 int TaskManagerSharedWorkerResource::GetUniqueChildProcessId() const { 123 int TaskManagerSharedWorkerResource::GetUniqueChildProcessId() const {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 int process_id = resource->process_id(); 355 int process_id = resource->process_id();
356 launching_workers_[process_id].push_back(resource); 356 launching_workers_[process_id].push_back(resource);
357 } else { 357 } else {
358 task_manager_->AddResource(resource); 358 task_manager_->AddResource(resource);
359 } 359 }
360 } 360 }
361 361
362 void TaskManagerWorkerResourceProvider::DeleteAllResources() { 362 void TaskManagerWorkerResourceProvider::DeleteAllResources() {
363 STLDeleteElements(&resources_); 363 STLDeleteElements(&resources_);
364 } 364 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698