Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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 "content/browser/profiler_controller_impl.h" | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/values.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 #include "content/public/browser/profiler_subscriber.h" | |
| 11 | |
| 12 using content::BrowserThread; | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 content::ProfilerController* content::ProfilerController::GetInstance() { | |
| 17 return ProfilerControllerImpl::GetInstance(); | |
| 18 } | |
| 19 | |
| 20 ProfilerControllerImpl* ProfilerControllerImpl::GetInstance() { | |
| 21 return Singleton<ProfilerControllerImpl>::get(); | |
| 22 } | |
| 23 | |
| 24 ProfilerControllerImpl::ProfilerControllerImpl() : subscriber_(NULL) { | |
| 25 } | |
| 26 | |
| 27 ProfilerControllerImpl::~ProfilerControllerImpl() { | |
| 28 } | |
| 29 | |
| 30 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) { | |
| 31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 32 DCHECK(!subscriber_); | |
| 33 subscriber_ = subscriber; | |
| 34 } | |
| 35 | |
| 36 void ProfilerControllerImpl::Unregister(ProfilerSubscriber* subscriber) { | |
| 37 if (subscriber == subscriber_) | |
| 38 subscriber_ = NULL; | |
| 39 } | |
| 40 | |
| 41 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number, | |
| 42 int pending_processes) { | |
| 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 44 if (subscriber_) | |
| 45 subscriber_->OnPendingProcesses(sequence_number, pending_processes); | |
| 46 } | |
| 47 | |
| 48 void ProfilerControllerImpl::OnProfilerDataCollected( | |
| 49 int sequence_number, | |
| 50 base::DictionaryValue* profiler_data) { | |
| 51 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.
| |
| 52 BrowserThread::PostTask( | |
| 53 BrowserThread::UI, FROM_HERE, | |
| 54 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected, | |
| 55 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.
| |
| 56 sequence_number, | |
| 57 profiler_data)); | |
| 58 return; | |
| 59 } | |
| 60 | |
| 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 62 if (subscriber_) | |
| 63 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data); | |
| 64 } | |
| 65 | |
| 66 } // namespace content | |
| OLD | NEW |