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

Side by Side Diff: ash/touch/touch_hud_debug.cc

Issue 1867223004: Convert //ash from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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 | « ash/touch/touch_hud_debug.h ('k') | ash/touch/touch_hud_projection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ash/touch/touch_hud_debug.h" 5 #include "ash/touch/touch_hud_debug.h"
6 6
7 #include "ash/display/display_manager.h" 7 #include "ash/display/display_manager.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "base/json/json_string_value_serializer.h" 10 #include "base/json/json_string_value_serializer.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 location(touch.root_location()), 94 location(touch.root_location()),
95 timestamp(touch.time_stamp().InMillisecondsF()), 95 timestamp(touch.time_stamp().InMillisecondsF()),
96 radius_x(touch.pointer_details().radius_x), 96 radius_x(touch.pointer_details().radius_x),
97 radius_y(touch.pointer_details().radius_y), 97 radius_y(touch.pointer_details().radius_y),
98 pressure(touch.pointer_details().force), 98 pressure(touch.pointer_details().force),
99 tracking_id(GetTrackingId(touch)), 99 tracking_id(GetTrackingId(touch)),
100 source_device(touch.source_device_id()) {} 100 source_device(touch.source_device_id()) {}
101 101
102 // Populates a dictionary value with all the information about the touch 102 // Populates a dictionary value with all the information about the touch
103 // point. 103 // point.
104 scoped_ptr<base::DictionaryValue> GetAsDictionary() const { 104 std::unique_ptr<base::DictionaryValue> GetAsDictionary() const {
105 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 105 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
106 106
107 value->SetInteger("id", id); 107 value->SetInteger("id", id);
108 value->SetString("type", std::string(GetTouchEventLabel(type))); 108 value->SetString("type", std::string(GetTouchEventLabel(type)));
109 value->SetString("location", location.ToString()); 109 value->SetString("location", location.ToString());
110 value->SetDouble("timestamp", timestamp); 110 value->SetDouble("timestamp", timestamp);
111 value->SetDouble("radius_x", radius_x); 111 value->SetDouble("radius_x", radius_x);
112 value->SetDouble("radius_y", radius_y); 112 value->SetDouble("radius_y", radius_y);
113 value->SetDouble("pressure", pressure); 113 value->SetDouble("pressure", pressure);
114 value->SetInteger("tracking_id", tracking_id); 114 value->SetInteger("tracking_id", tracking_id);
115 value->SetInteger("source_device", source_device); 115 value->SetInteger("source_device", source_device);
(...skipping 30 matching lines...) Expand all
146 } 146 }
147 147
148 const std::vector<TouchPointLog>& log() const { return log_; } 148 const std::vector<TouchPointLog>& log() const { return log_; }
149 149
150 bool active() const { 150 bool active() const {
151 return !log_.empty() && log_.back().type != ui::ET_TOUCH_RELEASED && 151 return !log_.empty() && log_.back().type != ui::ET_TOUCH_RELEASED &&
152 log_.back().type != ui::ET_TOUCH_CANCELLED; 152 log_.back().type != ui::ET_TOUCH_CANCELLED;
153 } 153 }
154 154
155 // Returns a list containing data from all events for the touch point. 155 // Returns a list containing data from all events for the touch point.
156 scoped_ptr<base::ListValue> GetAsList() const { 156 std::unique_ptr<base::ListValue> GetAsList() const {
157 scoped_ptr<base::ListValue> list(new base::ListValue()); 157 std::unique_ptr<base::ListValue> list(new base::ListValue());
158 for (const_iterator i = log_.begin(); i != log_.end(); ++i) 158 for (const_iterator i = log_.begin(); i != log_.end(); ++i)
159 list->Append((*i).GetAsDictionary().release()); 159 list->Append((*i).GetAsDictionary().release());
160 return list; 160 return list;
161 } 161 }
162 162
163 void Reset() { 163 void Reset() {
164 log_.clear(); 164 log_.clear();
165 } 165 }
166 166
167 private: 167 private:
(...skipping 13 matching lines...) Expand all
181 StartTrace(touch); 181 StartTrace(touch);
182 AddToTrace(touch); 182 AddToTrace(touch);
183 } 183 }
184 184
185 void Reset() { 185 void Reset() {
186 next_trace_index_ = 0; 186 next_trace_index_ = 0;
187 for (int i = 0; i < kMaxPaths; ++i) 187 for (int i = 0; i < kMaxPaths; ++i)
188 traces_[i].Reset(); 188 traces_[i].Reset();
189 } 189 }
190 190
191 scoped_ptr<base::ListValue> GetAsList() const { 191 std::unique_ptr<base::ListValue> GetAsList() const {
192 scoped_ptr<base::ListValue> list(new base::ListValue()); 192 std::unique_ptr<base::ListValue> list(new base::ListValue());
193 for (int i = 0; i < kMaxPaths; ++i) { 193 for (int i = 0; i < kMaxPaths; ++i) {
194 if (!traces_[i].log().empty()) 194 if (!traces_[i].log().empty())
195 list->Append(traces_[i].GetAsList().release()); 195 list->Append(traces_[i].GetAsList().release());
196 } 196 }
197 return list; 197 return list;
198 } 198 }
199 199
200 int GetTraceIndex(int touch_id) const { 200 int GetTraceIndex(int touch_id) const {
201 return touch_id_to_trace_index_.at(touch_id); 201 return touch_id_to_trace_index_.at(touch_id);
202 } 202 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 label_container_->SetY(display_size.height() / kReducedScale); 350 label_container_->SetY(display_size.height() / kReducedScale);
351 label_container_->SetSize(label_container_->GetPreferredSize()); 351 label_container_->SetSize(label_container_->GetPreferredSize());
352 label_container_->SetVisible(false); 352 label_container_->SetVisible(false);
353 content->AddChildView(label_container_); 353 content->AddChildView(label_container_);
354 } 354 }
355 355
356 TouchHudDebug::~TouchHudDebug() { 356 TouchHudDebug::~TouchHudDebug() {
357 } 357 }
358 358
359 // static 359 // static
360 scoped_ptr<base::DictionaryValue> TouchHudDebug::GetAllAsDictionary() { 360 std::unique_ptr<base::DictionaryValue> TouchHudDebug::GetAllAsDictionary() {
361 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); 361 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
362 aura::Window::Windows roots = Shell::GetInstance()->GetAllRootWindows(); 362 aura::Window::Windows roots = Shell::GetInstance()->GetAllRootWindows();
363 for (aura::Window::Windows::iterator iter = roots.begin(); 363 for (aura::Window::Windows::iterator iter = roots.begin();
364 iter != roots.end(); ++iter) { 364 iter != roots.end(); ++iter) {
365 RootWindowController* controller = GetRootWindowController(*iter); 365 RootWindowController* controller = GetRootWindowController(*iter);
366 TouchHudDebug* hud = controller->touch_hud_debug(); 366 TouchHudDebug* hud = controller->touch_hud_debug();
367 if (hud) { 367 if (hud) {
368 scoped_ptr<base::ListValue> list = hud->GetLogAsList(); 368 std::unique_ptr<base::ListValue> list = hud->GetLogAsList();
369 if (!list->empty()) 369 if (!list->empty())
370 value->Set(base::Int64ToString(hud->display_id()), list.release()); 370 value->Set(base::Int64ToString(hud->display_id()), list.release());
371 } 371 }
372 } 372 }
373 return value; 373 return value;
374 } 374 }
375 375
376 void TouchHudDebug::ChangeToNextMode() { 376 void TouchHudDebug::ChangeToNextMode() {
377 switch (mode_) { 377 switch (mode_) {
378 case FULLSCREEN: 378 case FULLSCREEN:
379 SetMode(REDUCED_SCALE); 379 SetMode(REDUCED_SCALE);
380 break; 380 break;
381 case REDUCED_SCALE: 381 case REDUCED_SCALE:
382 SetMode(INVISIBLE); 382 SetMode(INVISIBLE);
383 break; 383 break;
384 case INVISIBLE: 384 case INVISIBLE:
385 SetMode(FULLSCREEN); 385 SetMode(FULLSCREEN);
386 break; 386 break;
387 } 387 }
388 } 388 }
389 389
390 scoped_ptr<base::ListValue> TouchHudDebug::GetLogAsList() const { 390 std::unique_ptr<base::ListValue> TouchHudDebug::GetLogAsList() const {
391 return touch_log_->GetAsList(); 391 return touch_log_->GetAsList();
392 } 392 }
393 393
394 void TouchHudDebug::Clear() { 394 void TouchHudDebug::Clear() {
395 if (widget()->IsVisible()) { 395 if (widget()->IsVisible()) {
396 canvas_->Clear(); 396 canvas_->Clear();
397 for (int i = 0; i < kMaxTouchPoints; ++i) 397 for (int i = 0; i < kMaxTouchPoints; ++i)
398 touch_labels_[i]->SetText(base::string16()); 398 touch_labels_[i]->SetText(base::string16());
399 label_container_->SetSize(label_container_->GetPreferredSize()); 399 label_container_->SetSize(label_container_->GetPreferredSize());
400 } 400 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 RootWindowController* controller) { 469 RootWindowController* controller) {
470 controller->set_touch_hud_debug(this); 470 controller->set_touch_hud_debug(this);
471 } 471 }
472 472
473 void TouchHudDebug::UnsetHudForRootWindowController( 473 void TouchHudDebug::UnsetHudForRootWindowController(
474 RootWindowController* controller) { 474 RootWindowController* controller) {
475 controller->set_touch_hud_debug(NULL); 475 controller->set_touch_hud_debug(NULL);
476 } 476 }
477 477
478 } // namespace ash 478 } // namespace ash
OLDNEW
« no previous file with comments | « ash/touch/touch_hud_debug.h ('k') | ash/touch/touch_hud_projection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698