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.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "content/browser/browser_message_filter.h" |
| 9 #include "content/browser/profiler_message_filter.h" |
| 10 |
| 11 using content::BrowserThread; |
| 12 |
| 13 ProfilerSubscriber::~ProfilerSubscriber() { |
| 14 } |
| 15 |
| 16 ProfilerController::ProfilerController() : subscriber_(NULL) { |
| 17 } |
| 18 |
| 19 ProfilerController::~ProfilerController() { |
| 20 } |
| 21 |
| 22 ProfilerController* ProfilerController::GetInstance() { |
| 23 return Singleton<ProfilerController>::get(); |
| 24 } |
| 25 |
| 26 void ProfilerController::RegisterSubscriber(ProfilerSubscriber* subscriber) { |
| 27 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 28 DCHECK(!subscriber_); |
| 29 subscriber_ = subscriber; |
| 30 } |
| 31 |
| 32 void ProfilerController::CancelSubscriber(ProfilerSubscriber* subscriber) { |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 34 |
| 35 if (subscriber == subscriber_) { |
| 36 subscriber_ = NULL; |
| 37 } |
| 38 } |
| 39 |
| 40 void ProfilerController::OnProfilerDataCollected( |
| 41 int sequence_number, |
| 42 const std::string& profiler_data) { |
| 43 if (subscriber_) { |
| 44 subscriber_->OnBrowserChildProfilerDataCollected( |
| 45 sequence_number, profiler_data); |
| 46 } |
| 47 } |
| 48 |
| 49 void ProfilerController::OnIsProfilerEnabled(base::ProcessId child_process_id) { |
| 50 if (subscriber_) { |
| 51 subscriber_->OnIsProfilerEnabledForChildProcess(child_process_id); |
| 52 } |
| 53 } |
OLD | NEW |