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

Side by Side Diff: cc/debug/frame_timing_tracker_unittest.cc

Issue 1717283003: tracing: Make ConvertableToTraceFormat move-only scoped_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "base/trace_event/trace_event_argument.h" 11 #include "base/trace_event/trace_event_argument.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "cc/debug/frame_timing_tracker.h" 13 #include "cc/debug/frame_timing_tracker.h"
14 #include "cc/test/fake_impl_task_runner_provider.h" 14 #include "cc/test/fake_impl_task_runner_provider.h"
15 #include "cc/test/fake_layer_tree_host_impl.h" 15 #include "cc/test/fake_layer_tree_host_impl.h"
16 #include "cc/test/test_shared_bitmap_manager.h" 16 #include "cc/test/test_shared_bitmap_manager.h"
17 #include "cc/test/test_task_graph_runner.h" 17 #include "cc/test/test_task_graph_runner.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace cc { 20 namespace cc {
21 namespace { 21 namespace {
22 22
23 std::string CompositeToString( 23 std::string CompositeToString(
24 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timingset) { 24 scoped_ptr<FrameTimingTracker::CompositeTimingSet> timingset) {
25 scoped_refptr<base::trace_event::TracedValue> value = 25 scoped_ptr<base::trace_event::TracedValue> value(
26 new base::trace_event::TracedValue(); 26 new base::trace_event::TracedValue());
27 value->BeginArray("values"); 27 value->BeginArray("values");
28 std::set<int> rect_ids; 28 std::set<int> rect_ids;
29 for (const auto& pair : *timingset) 29 for (const auto& pair : *timingset)
30 rect_ids.insert(pair.first); 30 rect_ids.insert(pair.first);
31 31
32 for (const auto& rect_id : rect_ids) { 32 for (const auto& rect_id : rect_ids) {
33 auto& events = (*timingset)[rect_id]; 33 auto& events = (*timingset)[rect_id];
34 value->BeginDictionary(); 34 value->BeginDictionary();
35 value->SetInteger("rect_id", rect_id); 35 value->SetInteger("rect_id", rect_id);
36 value->BeginArray("events"); 36 value->BeginArray("events");
37 for (const auto& event : events) { 37 for (const auto& event : events) {
38 value->BeginDictionary(); 38 value->BeginDictionary();
39 value->SetInteger("frame_id", event.frame_id); 39 value->SetInteger("frame_id", event.frame_id);
40 value->SetInteger("timestamp", event.timestamp.ToInternalValue()); 40 value->SetInteger("timestamp", event.timestamp.ToInternalValue());
41 value->EndDictionary(); 41 value->EndDictionary();
42 } 42 }
43 value->EndArray(); 43 value->EndArray();
44 value->EndDictionary(); 44 value->EndDictionary();
45 } 45 }
46 value->EndArray(); 46 value->EndArray();
47 return value->ToString(); 47 return value->ToString();
48 } 48 }
49 49
50 std::string MainFrameToString( 50 std::string MainFrameToString(
51 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> timingset) { 51 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> timingset) {
52 scoped_refptr<base::trace_event::TracedValue> value = 52 scoped_ptr<base::trace_event::TracedValue> value(
53 new base::trace_event::TracedValue(); 53 new base::trace_event::TracedValue());
54 value->BeginArray("values"); 54 value->BeginArray("values");
55 std::set<int> rect_ids; 55 std::set<int> rect_ids;
56 for (const auto& pair : *timingset) 56 for (const auto& pair : *timingset)
57 rect_ids.insert(pair.first); 57 rect_ids.insert(pair.first);
58 58
59 for (const auto& rect_id : rect_ids) { 59 for (const auto& rect_id : rect_ids) {
60 auto& events = (*timingset)[rect_id]; 60 auto& events = (*timingset)[rect_id];
61 value->BeginDictionary(); 61 value->BeginDictionary();
62 value->SetInteger("rect_id", rect_id); 62 value->SetInteger("rect_id", rect_id);
63 value->BeginArray("events"); 63 value->BeginArray("events");
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}," 288 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100},"
289 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," 289 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3},"
290 "{\"events\":[" 290 "{\"events\":["
291 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" 291 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}"
292 "]}", 292 "]}",
293 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); 293 MainFrameToString(tracker->GroupMainFrameCountsByRectId()));
294 } 294 }
295 295
296 } // namespace 296 } // namespace
297 } // namespace cc 297 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698