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

Side by Side Diff: content/browser/devtools/devtools_tracing_handler.cc

Issue 339743004: Add Tracing.getCategories to devtools_tracing_handler.cc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « content/browser/devtools/devtools_tracing_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/devtools/devtools_tracing_handler.h" 5 #include "content/browser/devtools/devtools_tracing_handler.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 DevToolsTracingHandler::DevToolsTracingHandler( 49 DevToolsTracingHandler::DevToolsTracingHandler(
50 DevToolsTracingHandler::Target target) 50 DevToolsTracingHandler::Target target)
51 : weak_factory_(this), target_(target) { 51 : weak_factory_(this), target_(target) {
52 RegisterCommandHandler(devtools::Tracing::start::kName, 52 RegisterCommandHandler(devtools::Tracing::start::kName,
53 base::Bind(&DevToolsTracingHandler::OnStart, 53 base::Bind(&DevToolsTracingHandler::OnStart,
54 base::Unretained(this))); 54 base::Unretained(this)));
55 RegisterCommandHandler(devtools::Tracing::end::kName, 55 RegisterCommandHandler(devtools::Tracing::end::kName,
56 base::Bind(&DevToolsTracingHandler::OnEnd, 56 base::Bind(&DevToolsTracingHandler::OnEnd,
57 base::Unretained(this))); 57 base::Unretained(this)));
58 RegisterCommandHandler(devtools::Tracing::getCategories::kName,
59 base::Bind(&DevToolsTracingHandler::OnGetCategories,
60 base::Unretained(this)));
58 } 61 }
59 62
60 DevToolsTracingHandler::~DevToolsTracingHandler() { 63 DevToolsTracingHandler::~DevToolsTracingHandler() {
61 } 64 }
62 65
63 void DevToolsTracingHandler::BeginReadingRecordingResult( 66 void DevToolsTracingHandler::BeginReadingRecordingResult(
64 const base::FilePath& path) { 67 const base::FilePath& path) {
65 BrowserThread::PostTask( 68 BrowserThread::PostTask(
66 BrowserThread::FILE, FROM_HERE, 69 BrowserThread::FILE, FROM_HERE,
67 base::Bind(&ReadFile, path, 70 base::Bind(&ReadFile, path,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 const TracingController::TracingFileResultCallback& callback) { 213 const TracingController::TracingFileResultCallback& callback) {
211 buffer_usage_poll_timer_.reset(); 214 buffer_usage_poll_timer_.reset();
212 TracingController::GetInstance()->DisableRecording(base::FilePath(), 215 TracingController::GetInstance()->DisableRecording(base::FilePath(),
213 callback); 216 callback);
214 } 217 }
215 218
216 void DevToolsTracingHandler::OnClientDetached() { 219 void DevToolsTracingHandler::OnClientDetached() {
217 DisableRecording(); 220 DisableRecording();
218 } 221 }
219 222
223 scoped_refptr<DevToolsProtocol::Response>
224 DevToolsTracingHandler::OnGetCategories(
225 scoped_refptr<DevToolsProtocol::Command> command) {
226 TracingController::GetInstance()->GetCategories(
227 base::Bind(&DevToolsTracingHandler::OnCategoriesReceived,
228 weak_factory_.GetWeakPtr(),
229 command));
230 return command->AsyncResponsePromise();
231 }
232
233 void DevToolsTracingHandler::OnCategoriesReceived(
234 scoped_refptr<DevToolsProtocol::Command> command,
235 const std::set<std::string>& category_set) {
236 base::DictionaryValue* response = new base::DictionaryValue;
237 base::ListValue* category_list = new base::ListValue;
238 for (std::set<std::string>::const_iterator it = category_set.begin();
239 it != category_set.end(); ++it) {
240 category_list->AppendString(*it);
241 }
242
243 response->Set(devtools::Tracing::getCategories::kResponseCategories,
244 category_list);
245 SendAsyncResponse(command->SuccessResponse(response));
246 }
247
220 } // namespace content 248 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/devtools_tracing_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698