| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/tracing/tracing_ui.h" | 5 #include "content/browser/tracing/tracing_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 // A proxy passed to the Read and Write tasks used when loading or saving trace | 119 // A proxy passed to the Read and Write tasks used when loading or saving trace |
| 120 // data. | 120 // data. |
| 121 class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> { | 121 class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> { |
| 122 public: | 122 public: |
| 123 explicit TaskProxy(const base::WeakPtr<TracingMessageHandler>& handler) | 123 explicit TaskProxy(const base::WeakPtr<TracingMessageHandler>& handler) |
| 124 : handler_(handler) {} | 124 : handler_(handler) {} |
| 125 void LoadTraceFileCompleteProxy(string16* file_contents, | 125 void LoadTraceFileCompleteProxy(string16* file_contents, |
| 126 const base::FilePath& path) { | 126 const base::FilePath& path) { |
| 127 if (handler_) | 127 if (handler_.get()) |
| 128 handler_->LoadTraceFileComplete(file_contents, path); | 128 handler_->LoadTraceFileComplete(file_contents, path); |
| 129 delete file_contents; | 129 delete file_contents; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void SaveTraceFileCompleteProxy() { | 132 void SaveTraceFileCompleteProxy() { |
| 133 if (handler_) | 133 if (handler_.get()) |
| 134 handler_->SaveTraceFileComplete(); | 134 handler_->SaveTraceFileComplete(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 private: | 137 private: |
| 138 friend class base::RefCountedThreadSafe<TaskProxy>; | 138 friend class base::RefCountedThreadSafe<TaskProxy>; |
| 139 ~TaskProxy() {} | 139 ~TaskProxy() {} |
| 140 | 140 |
| 141 // The message handler to call callbacks on. | 141 // The message handler to call callbacks on. |
| 142 base::WeakPtr<TracingMessageHandler> handler_; | 142 base::WeakPtr<TracingMessageHandler> handler_; |
| 143 | 143 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { | 552 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { |
| 553 web_ui->AddMessageHandler(new TracingMessageHandler()); | 553 web_ui->AddMessageHandler(new TracingMessageHandler()); |
| 554 | 554 |
| 555 // Set up the chrome://tracing/ source. | 555 // Set up the chrome://tracing/ source. |
| 556 BrowserContext* browser_context = | 556 BrowserContext* browser_context = |
| 557 web_ui->GetWebContents()->GetBrowserContext(); | 557 web_ui->GetWebContents()->GetBrowserContext(); |
| 558 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); | 558 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); |
| 559 } | 559 } |
| 560 | 560 |
| 561 } // namespace content | 561 } // namespace content |
| OLD | NEW |