Chromium Code Reviews| Index: content/browser/profiler_controller_impl.cc |
| =================================================================== |
| --- content/browser/profiler_controller_impl.cc (revision 0) |
| +++ content/browser/profiler_controller_impl.cc (revision 0) |
| @@ -0,0 +1,66 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/profiler_controller_impl.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/values.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/profiler_subscriber.h" |
| + |
| +using content::BrowserThread; |
| + |
| +namespace content { |
| + |
| +content::ProfilerController* content::ProfilerController::GetInstance() { |
| + return ProfilerControllerImpl::GetInstance(); |
| +} |
| + |
| +ProfilerControllerImpl* ProfilerControllerImpl::GetInstance() { |
| + return Singleton<ProfilerControllerImpl>::get(); |
| +} |
| + |
| +ProfilerControllerImpl::ProfilerControllerImpl() : subscriber_(NULL) { |
| +} |
| + |
| +ProfilerControllerImpl::~ProfilerControllerImpl() { |
| +} |
| + |
| +void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + DCHECK(!subscriber_); |
| + subscriber_ = subscriber; |
| +} |
| + |
| +void ProfilerControllerImpl::Unregister(ProfilerSubscriber* subscriber) { |
| + if (subscriber == subscriber_) |
| + subscriber_ = NULL; |
| +} |
| + |
| +void ProfilerControllerImpl::OnPendingProcesses(int sequence_number, |
| + int pending_processes) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + if (subscriber_) |
| + subscriber_->OnPendingProcesses(sequence_number, pending_processes); |
| +} |
| + |
| +void ProfilerControllerImpl::OnProfilerDataCollected( |
| + int sequence_number, |
| + base::DictionaryValue* profiler_data) { |
| + if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
|
jam
2011/11/30 00:22:25
nit: usually this is written as
(!BrowserThread::
ramant (doing other things)
2011/11/30 19:37:21
Done.
|
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected, |
| + base::Unretained(this), |
|
jam
2011/11/30 00:22:25
using base::Unretained, you're assuming that this
ramant (doing other things)
2011/11/30 19:37:21
Done.
jam
2011/12/01 03:43:17
oops, i'm really sorry. I forgot that this object
ramant (doing other things)
2011/12/01 21:33:35
Done.
|
| + sequence_number, |
| + profiler_data)); |
| + return; |
| + } |
| + |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + if (subscriber_) |
| + subscriber_->OnProfilerDataCollected(sequence_number, profiler_data); |
| +} |
| + |
| +} // namespace content |
| Property changes on: content\browser\profiler_controller_impl.cc |
| ___________________________________________________________________ |
| Added: svn:executable |
| + * |