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

Unified Diff: chrome/browser/task_manager/notification_resource_provider.cc

Issue 15196003: Create task_manager namespace and wrap classes related to TaskManager with it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RendererResource Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/task_manager/notification_resource_provider.cc
diff --git a/chrome/browser/task_manager/task_manager_notification_resource_provider.cc b/chrome/browser/task_manager/notification_resource_provider.cc
similarity index 62%
rename from chrome/browser/task_manager/task_manager_notification_resource_provider.cc
rename to chrome/browser/task_manager/notification_resource_provider.cc
index 539ec4b25c9c7d8aa2197184577cda63f72c62c2..56b1db37c19ce51d536dc9e6d8b62ce0c9d84c6d 100644
--- a/chrome/browser/task_manager/task_manager_notification_resource_provider.cc
+++ b/chrome/browser/task_manager/notification_resource_provider.cc
@@ -1,22 +1,17 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
yoshiki 2013/05/20 04:50:02 We shouldn't change the year in copyright in exist
peria 2013/05/20 05:39:04 Done.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/task_manager/task_manager_notification_resource_provider.h"
+#include "chrome/browser/task_manager/notification_resource_provider.h"
-#include "base/basictypes.h"
-#include "base/stl_util.h"
+#include "base/string16.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window.h"
-#include "chrome/browser/notifications/balloon.h"
-#include "chrome/browser/notifications/balloon_collection.h"
#include "chrome/browser/notifications/balloon_host.h"
#include "chrome/browser/notifications/balloon_notification_ui_manager.h"
-#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
-#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -24,14 +19,44 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
-////////////////////////////////////////////////////////////////////////////////
-// TaskManagerNotificationResource class
-////////////////////////////////////////////////////////////////////////////////
+namespace task_manager {
+
+class NotificationResource : public TaskManager::Resource {
+ public:
+ explicit NotificationResource(BalloonHost* balloon_host);
+ virtual ~NotificationResource();
+
+ // TaskManager::Resource interface
+ virtual string16 GetTitle() const OVERRIDE;
+ virtual string16 GetProfileName() const OVERRIDE;
+ virtual gfx::ImageSkia GetIcon() const OVERRIDE;
+ virtual base::ProcessHandle GetProcess() const OVERRIDE;
+ virtual int GetUniqueChildProcessId() const OVERRIDE;
+ virtual Type GetType() const OVERRIDE;
+ virtual bool CanInspect() const OVERRIDE;
+ virtual void Inspect() const OVERRIDE;
+ virtual bool SupportNetworkUsage() const OVERRIDE;
+ virtual void SetSupportNetworkUsage() OVERRIDE { }
+
+ private:
+ // The icon painted for notifications. .
+ static gfx::ImageSkia* default_icon_;
-gfx::ImageSkia* TaskManagerNotificationResource::default_icon_ = NULL;
+ // Non-owned pointer to the balloon host.
+ BalloonHost* balloon_host_;
-TaskManagerNotificationResource::TaskManagerNotificationResource(
- BalloonHost* balloon_host)
+ // Cached data about the balloon host.
+ base::ProcessHandle process_handle_;
+ int pid_;
+ int unique_process_id_;
+ string16 title_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationResource);
+};
+
+gfx::ImageSkia* NotificationResource::default_icon_ = NULL;
+
+NotificationResource::NotificationResource(BalloonHost* balloon_host)
: balloon_host_(balloon_host) {
if (!default_icon_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
@@ -46,67 +71,66 @@ TaskManagerNotificationResource::TaskManagerNotificationResource(
balloon_host_->GetSource());
}
-TaskManagerNotificationResource::~TaskManagerNotificationResource() {
+NotificationResource::~NotificationResource() {
}
-string16 TaskManagerNotificationResource::GetTitle() const {
+string16 NotificationResource::GetTitle() const {
return title_;
}
-string16 TaskManagerNotificationResource::GetProfileName() const {
+string16 NotificationResource::GetProfileName() const {
return string16();
}
-gfx::ImageSkia TaskManagerNotificationResource::GetIcon() const {
+gfx::ImageSkia NotificationResource::GetIcon() const {
return *default_icon_;
}
-base::ProcessHandle TaskManagerNotificationResource::GetProcess() const {
+base::ProcessHandle NotificationResource::GetProcess() const {
return process_handle_;
}
-int TaskManagerNotificationResource::GetUniqueChildProcessId() const {
+int NotificationResource::GetUniqueChildProcessId() const {
return unique_process_id_;
}
-TaskManager::Resource::Type TaskManagerNotificationResource::GetType() const {
+TaskManager::Resource::Type NotificationResource::GetType() const {
return NOTIFICATION;
}
-bool TaskManagerNotificationResource::CanInspect() const {
+bool NotificationResource::CanInspect() const {
return true;
}
-void TaskManagerNotificationResource::Inspect() const {
+void NotificationResource::Inspect() const {
DevToolsWindow::OpenDevToolsWindow(
balloon_host_->web_contents()->GetRenderViewHost());
}
-bool TaskManagerNotificationResource::SupportNetworkUsage() const {
+bool NotificationResource::SupportNetworkUsage() const {
return false;
}
////////////////////////////////////////////////////////////////////////////////
-// TaskManagerNotificationResourceProvider class
+// NotificationResourceProvider class
////////////////////////////////////////////////////////////////////////////////
// static
-TaskManagerNotificationResourceProvider*
-TaskManagerNotificationResourceProvider::Create(TaskManager* task_manager) {
- return new TaskManagerNotificationResourceProvider(task_manager);
+NotificationResourceProvider*
+NotificationResourceProvider::Create(TaskManager* task_manager) {
+ return new NotificationResourceProvider(task_manager);
}
-TaskManagerNotificationResourceProvider::
- TaskManagerNotificationResourceProvider(TaskManager* task_manager)
+NotificationResourceProvider::
+ NotificationResourceProvider(TaskManager* task_manager)
: task_manager_(task_manager),
updating_(false) {
}
-TaskManagerNotificationResourceProvider::
- ~TaskManagerNotificationResourceProvider() {
+NotificationResourceProvider::~NotificationResourceProvider() {
}
-TaskManager::Resource* TaskManagerNotificationResourceProvider::GetResource(
+TaskManager::Resource* NotificationResourceProvider::GetResource(
int origin_pid,
int render_process_host_id,
int routing_id) {
@@ -114,7 +138,7 @@ TaskManager::Resource* TaskManagerNotificationResourceProvider::GetResource(
return NULL;
}
-void TaskManagerNotificationResourceProvider::StartUpdating() {
+void NotificationResourceProvider::StartUpdating() {
// MessageCenter does not use Balloons.
if (NotificationUIManager::DelegatesToMessageCenter())
return;
@@ -142,7 +166,7 @@ void TaskManagerNotificationResourceProvider::StartUpdating() {
content::NotificationService::AllSources());
}
-void TaskManagerNotificationResourceProvider::StopUpdating() {
+void NotificationResourceProvider::StopUpdating() {
// MessageCenter does not use Balloons.
if (NotificationUIManager::DelegatesToMessageCenter())
return;
@@ -161,7 +185,7 @@ void TaskManagerNotificationResourceProvider::StopUpdating() {
resources_.clear();
}
-void TaskManagerNotificationResourceProvider::Observe(
+void NotificationResourceProvider::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -178,26 +202,25 @@ void TaskManagerNotificationResourceProvider::Observe(
}
}
-void TaskManagerNotificationResourceProvider::AddToTaskManager(
+void NotificationResourceProvider::AddToTaskManager(
BalloonHost* balloon_host) {
- TaskManagerNotificationResource* resource =
- new TaskManagerNotificationResource(balloon_host);
+ NotificationResource* resource = new NotificationResource(balloon_host);
DCHECK(resources_.find(balloon_host) == resources_.end());
resources_[balloon_host] = resource;
task_manager_->AddResource(resource);
}
-void TaskManagerNotificationResourceProvider::RemoveFromTaskManager(
+void NotificationResourceProvider::RemoveFromTaskManager(
BalloonHost* balloon_host) {
if (!updating_)
return;
- std::map<BalloonHost*, TaskManagerNotificationResource*>::iterator iter =
+ std::map<BalloonHost*, NotificationResource*>::iterator iter =
resources_.find(balloon_host);
if (iter == resources_.end())
return;
// Remove the resource from the Task Manager.
- TaskManagerNotificationResource* resource = iter->second;
+ NotificationResource* resource = iter->second;
task_manager_->RemoveResource(resource);
// Remove it from the map.
@@ -206,3 +229,5 @@ void TaskManagerNotificationResourceProvider::RemoveFromTaskManager(
// Finally, delete the resource.
delete resource;
}
+
+} // namespace task_manager

Powered by Google App Engine
This is Rietveld 408576698