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

Side by Side Diff: content/browser/devtools/protocol/tracing_handler.cc

Issue 642263004: [DevTools] Make generated protocol structs wrappers around DictionaryValue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix that will be needed for browser protocol Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/protocol/tracing_handler.h" 5 #include "content/browser/devtools/protocol/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/debug/trace_event_impl.h" 10 #include "base/debug/trace_event_impl.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 std::string message( 73 std::string message(
74 "{ \"method\": \"Tracing.dataCollected\", \"params\": { \"value\": ["); 74 "{ \"method\": \"Tracing.dataCollected\", \"params\": { \"value\": [");
75 const size_t messageSuffixSize = 10; 75 const size_t messageSuffixSize = 10;
76 message.reserve(message.size() + trace_fragment.size() + messageSuffixSize); 76 message.reserve(message.size() + trace_fragment.size() + messageSuffixSize);
77 message += trace_fragment; 77 message += trace_fragment;
78 message += "] } }"; 78 message += "] } }";
79 client_->SendRawMessage(message); 79 client_->SendRawMessage(message);
80 } 80 }
81 81
82 void TracingHandler::OnTraceComplete() { 82 void TracingHandler::OnTraceComplete() {
83 TracingCompleteParams params; 83 client_->TracingComplete(TracingCompleteParams::Create());
84 client_->TracingComplete(params);
85 } 84 }
86 85
87 scoped_refptr<DevToolsProtocol::Response> TracingHandler::Start( 86 scoped_refptr<DevToolsProtocol::Response> TracingHandler::Start(
88 const std::string* categories, 87 const std::string* categories,
89 const std::string* options_str, 88 const std::string* options_str,
90 const double* buffer_usage_reporting_interval, 89 const double* buffer_usage_reporting_interval,
91 scoped_refptr<DevToolsProtocol::Command> command) { 90 scoped_refptr<DevToolsProtocol::Command> command) {
92 if (is_recording_) 91 if (is_recording_)
93 return command->InternalErrorResponse("Tracing is already started"); 92 return command->InternalErrorResponse("Tracing is already started");
94 is_recording_ = true; 93 is_recording_ = true;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 scoped_refptr<DevToolsProtocol::Command> command) { 132 scoped_refptr<DevToolsProtocol::Command> command) {
134 TracingController::GetInstance()->GetCategories( 133 TracingController::GetInstance()->GetCategories(
135 base::Bind(&TracingHandler::OnCategoriesReceived, 134 base::Bind(&TracingHandler::OnCategoriesReceived,
136 weak_factory_.GetWeakPtr(), 135 weak_factory_.GetWeakPtr(),
137 command)); 136 command));
138 return command->AsyncResponsePromise(); 137 return command->AsyncResponsePromise();
139 } 138 }
140 139
141 void TracingHandler::OnRecordingEnabled( 140 void TracingHandler::OnRecordingEnabled(
142 scoped_refptr<DevToolsProtocol::Command> command) { 141 scoped_refptr<DevToolsProtocol::Command> command) {
143 StartResponse response; 142 client_->SendStartResponse(command, StartResponse::Create());
144 client_->SendStartResponse(command, response);
145 } 143 }
146 144
147 void TracingHandler::OnBufferUsage(float usage) { 145 void TracingHandler::OnBufferUsage(float usage) {
148 BufferUsageParams params; 146 client_->BufferUsage(BufferUsageParams::Create()->set_value(usage));
149 params.set_value(usage);
150 client_->BufferUsage(params);
151 } 147 }
152 148
153 void TracingHandler::OnCategoriesReceived( 149 void TracingHandler::OnCategoriesReceived(
154 scoped_refptr<DevToolsProtocol::Command> command, 150 scoped_refptr<DevToolsProtocol::Command> command,
155 const std::set<std::string>& category_set) { 151 const std::set<std::string>& category_set) {
156 std::vector<std::string> categories(category_set.begin(), category_set.end()); 152 std::vector<std::string> categories;
157 GetCategoriesResponse response; 153 for (const std::string& category : category_set)
158 response.set_categories(categories); 154 categories.push_back(category);
159 client_->SendGetCategoriesResponse(command, response); 155 client_->SendGetCategoriesResponse(command,
156 GetCategoriesResponse::Create()->set_categories(categories));
160 } 157 }
161 158
162 base::debug::TraceOptions TracingHandler::TraceOptionsFromString( 159 base::debug::TraceOptions TracingHandler::TraceOptionsFromString(
163 const std::string* options) { 160 const std::string* options) {
164 base::debug::TraceOptions ret; 161 base::debug::TraceOptions ret;
165 if (!options) 162 if (!options)
166 return ret; 163 return ret;
167 164
168 std::vector<std::string> split; 165 std::vector<std::string> split;
169 std::vector<std::string>::iterator iter; 166 std::vector<std::string>::iterator iter;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void TracingHandler::DisableRecording(bool abort) { 203 void TracingHandler::DisableRecording(bool abort) {
207 is_recording_ = false; 204 is_recording_ = false;
208 buffer_usage_poll_timer_.reset(); 205 buffer_usage_poll_timer_.reset();
209 TracingController::GetInstance()->DisableRecording( 206 TracingController::GetInstance()->DisableRecording(
210 abort ? nullptr : new DevToolsTraceSinkProxy(weak_factory_.GetWeakPtr())); 207 abort ? nullptr : new DevToolsTraceSinkProxy(weak_factory_.GetWeakPtr()));
211 } 208 }
212 209
213 } // namespace tracing 210 } // namespace tracing
214 } // namespace devtools 211 } // namespace devtools
215 } // namespace content 212 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/power_handler.cc ('k') | content/browser/devtools/protocol/usage_and_quota_query.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698