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

Side by Side Diff: content/browser/devtools/protocol/power_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: Created 6 years, 2 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
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/power_handler.h" 5 #include "content/browser/devtools/protocol/power_handler.h"
6 6
7 #include "content/browser/power_profiler/power_profiler_service.h" 7 #include "content/browser/power_profiler/power_profiler_service.h"
8 8
9 namespace content { 9 namespace content {
10 namespace devtools { 10 namespace devtools {
11 namespace power { 11 namespace power {
12 12
13 typedef DevToolsProtocolClient::Response Response; 13 typedef DevToolsProtocolClient::Response Response;
14 14
15 PowerHandler::PowerHandler() : enabled_(false) { 15 PowerHandler::PowerHandler() : enabled_(false) {
16 } 16 }
17 17
18 PowerHandler::~PowerHandler() { 18 PowerHandler::~PowerHandler() {
19 if (enabled_) 19 if (enabled_)
20 PowerProfilerService::GetInstance()->RemoveObserver(this); 20 PowerProfilerService::GetInstance()->RemoveObserver(this);
21 } 21 }
22 22
23 void PowerHandler::SetClient(scoped_ptr<Client> client) { 23 void PowerHandler::SetClient(scoped_ptr<Client> client) {
24 client_.swap(client); 24 client_.swap(client);
25 } 25 }
26 26
27 void PowerHandler::OnPowerEvent(const PowerEventVector& events) { 27 void PowerHandler::OnPowerEvent(const PowerEventVector& events) {
28 std::vector<PowerEvent> event_list; 28 scoped_ptr<ListBuilder<PowerEvent>> event_list;
29 for (const auto& event : events) { 29 for (const auto& event : events) {
30 PowerEvent event_body; 30 scoped_ptr<PowerEvent> event_body;
31 DCHECK(event.type < content::PowerEvent::ID_COUNT); 31 DCHECK(event.type < content::PowerEvent::ID_COUNT);
32 event_body.set_type(kPowerTypeNames[event.type]); 32 event_body->set_type(kPowerTypeNames[event.type]);
33 // Use internal value to be consistent with Blink's 33 // Use internal value to be consistent with Blink's
34 // monotonicallyIncreasingTime. 34 // monotonicallyIncreasingTime.
35 event_body.set_timestamp(event.time.ToInternalValue() / 35 event_body->set_timestamp(event.time.ToInternalValue() /
36 static_cast<double>(base::Time::kMicrosecondsPerMillisecond)); 36 static_cast<double>(base::Time::kMicrosecondsPerMillisecond));
37 event_body.set_value(event.value); 37 event_body->set_value(event.value);
38 event_list.push_back(event_body); 38 event_list->push_back(event_body.Pass());
39 } 39 }
40 DataAvailableParams params; 40 scoped_ptr<DataAvailableParams> params;
41 params.set_value(event_list); 41 params->set_value(event_list.Pass());
42 client_->DataAvailable(params); 42 client_->DataAvailable(params.Pass());
43 } 43 }
44 44
45 void PowerHandler::Detached() { 45 void PowerHandler::Detached() {
46 if (enabled_) { 46 if (enabled_) {
47 PowerProfilerService::GetInstance()->RemoveObserver(this); 47 PowerProfilerService::GetInstance()->RemoveObserver(this);
48 enabled_ = false; 48 enabled_ = false;
49 } 49 }
50 } 50 }
51 51
52 Response PowerHandler::Start() { 52 Response PowerHandler::Start() {
(...skipping 24 matching lines...) Expand all
77 Response PowerHandler::GetAccuracyLevel(std::string* result) { 77 Response PowerHandler::GetAccuracyLevel(std::string* result) {
78 if (!PowerProfilerService::GetInstance()->IsAvailable()) 78 if (!PowerProfilerService::GetInstance()->IsAvailable())
79 return Response::InternalError("Power profiler service unavailable"); 79 return Response::InternalError("Power profiler service unavailable");
80 *result = PowerProfilerService::GetInstance()->GetAccuracyLevel(); 80 *result = PowerProfilerService::GetInstance()->GetAccuracyLevel();
81 return Response::OK(); 81 return Response::OK();
82 } 82 }
83 83
84 } // namespace power 84 } // namespace power
85 } // namespace devtools 85 } // namespace devtools
86 } // namespace content 86 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698