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

Unified Diff: chrome/browser/ui/webui/tracing_ui.cc

Issue 8390018: Change GpuDataManager to use Observer notifications rather than callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Review fixes Created 9 years, 2 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
« no previous file with comments | « chrome/browser/ui/webui/gpu_internals_ui.cc ('k') | content/browser/gpu/gpu_data_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/tracing_ui.cc
===================================================================
--- chrome/browser/ui/webui/tracing_ui.cc (revision 107010)
+++ chrome/browser/ui/webui/tracing_ui.cc (working copy)
@@ -8,7 +8,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/callback_old.h"
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/memory/scoped_ptr.h"
@@ -48,7 +47,8 @@
: public WebUIMessageHandler,
public SelectFileDialog::Listener,
public base::SupportsWeakPtr<TracingMessageHandler>,
- public TraceSubscriber {
+ public TraceSubscriber,
+ public GpuDataManager::Observer {
public:
TracingMessageHandler();
virtual ~TracingMessageHandler();
@@ -66,6 +66,9 @@
virtual void OnTraceDataCollected(const std::string& trace_fragment);
virtual void OnTraceBufferPercentFullReply(float percent_full);
+ // GpuDataManager::Observer implementation.
+ virtual void OnGpuInfoUpdate() OVERRIDE;
+
// Messages.
void OnTracingControllerInitialized(const ListValue* list);
void OnBeginTracing(const ListValue* list);
@@ -75,9 +78,6 @@
void OnSaveTraceFile(const ListValue* list);
// Callbacks.
- void OnGpuInfoUpdate();
-
- // Callbacks.
void LoadTraceFileComplete(std::string* file_contents);
void SaveTraceFileComplete();
@@ -98,9 +98,6 @@
// Cache the Singleton for efficiency.
GpuDataManager* gpu_data_manager_;
- // Callback called when the GPU info is updated.
- Callback0::Type* gpu_info_update_callback_;
-
DISALLOW_COPY_AND_ASSIGN(TracingMessageHandler);
};
@@ -138,17 +135,13 @@
TracingMessageHandler::TracingMessageHandler()
: select_trace_file_dialog_type_(SelectFileDialog::SELECT_NONE),
- trace_enabled_(false),
- gpu_info_update_callback_(NULL) {
+ trace_enabled_(false) {
gpu_data_manager_ = GpuDataManager::GetInstance();
DCHECK(gpu_data_manager_);
}
TracingMessageHandler::~TracingMessageHandler() {
- if (gpu_info_update_callback_) {
- gpu_data_manager_->RemoveGpuInfoUpdateCallback(gpu_info_update_callback_);
- delete gpu_info_update_callback_;
- }
+ gpu_data_manager_->RemoveObserver(this);
if (select_trace_file_dialog_)
select_trace_file_dialog_->ListenerDestroyed();
@@ -190,12 +183,8 @@
const ListValue* args) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- DCHECK(!gpu_info_update_callback_);
-
// Watch for changes in GPUInfo
- gpu_info_update_callback_ =
- NewCallback(this, &TracingMessageHandler::OnGpuInfoUpdate);
- gpu_data_manager_->AddGpuInfoUpdateCallback(gpu_info_update_callback_);
+ gpu_data_manager_->AddObserver(this);
// Tell GpuDataManager it should have full GpuInfo. If the
// Gpu process has not run yet, this will trigger its launch.
« no previous file with comments | « chrome/browser/ui/webui/gpu_internals_ui.cc ('k') | content/browser/gpu/gpu_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698