| OLD | NEW |
| 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 auto value = make_scoped_ptr(new base::trace_event::TracedValue()); |
| 26 new base::trace_event::TracedValue(); | |
| 27 value->BeginArray("values"); | 26 value->BeginArray("values"); |
| 28 std::set<int> rect_ids; | 27 std::set<int> rect_ids; |
| 29 for (const auto& pair : *timingset) | 28 for (const auto& pair : *timingset) |
| 30 rect_ids.insert(pair.first); | 29 rect_ids.insert(pair.first); |
| 31 | 30 |
| 32 for (const auto& rect_id : rect_ids) { | 31 for (const auto& rect_id : rect_ids) { |
| 33 auto& events = (*timingset)[rect_id]; | 32 auto& events = (*timingset)[rect_id]; |
| 34 value->BeginDictionary(); | 33 value->BeginDictionary(); |
| 35 value->SetInteger("rect_id", rect_id); | 34 value->SetInteger("rect_id", rect_id); |
| 36 value->BeginArray("events"); | 35 value->BeginArray("events"); |
| 37 for (const auto& event : events) { | 36 for (const auto& event : events) { |
| 38 value->BeginDictionary(); | 37 value->BeginDictionary(); |
| 39 value->SetInteger("frame_id", event.frame_id); | 38 value->SetInteger("frame_id", event.frame_id); |
| 40 value->SetInteger("timestamp", event.timestamp.ToInternalValue()); | 39 value->SetInteger("timestamp", event.timestamp.ToInternalValue()); |
| 41 value->EndDictionary(); | 40 value->EndDictionary(); |
| 42 } | 41 } |
| 43 value->EndArray(); | 42 value->EndArray(); |
| 44 value->EndDictionary(); | 43 value->EndDictionary(); |
| 45 } | 44 } |
| 46 value->EndArray(); | 45 value->EndArray(); |
| 47 return value->ToString(); | 46 return value->ToString(); |
| 48 } | 47 } |
| 49 | 48 |
| 50 std::string MainFrameToString( | 49 std::string MainFrameToString( |
| 51 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> timingset) { | 50 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> timingset) { |
| 52 scoped_refptr<base::trace_event::TracedValue> value = | 51 auto value = make_scoped_ptr(new base::trace_event::TracedValue()); |
| 53 new base::trace_event::TracedValue(); | |
| 54 value->BeginArray("values"); | 52 value->BeginArray("values"); |
| 55 std::set<int> rect_ids; | 53 std::set<int> rect_ids; |
| 56 for (const auto& pair : *timingset) | 54 for (const auto& pair : *timingset) |
| 57 rect_ids.insert(pair.first); | 55 rect_ids.insert(pair.first); |
| 58 | 56 |
| 59 for (const auto& rect_id : rect_ids) { | 57 for (const auto& rect_id : rect_ids) { |
| 60 auto& events = (*timingset)[rect_id]; | 58 auto& events = (*timingset)[rect_id]; |
| 61 value->BeginDictionary(); | 59 value->BeginDictionary(); |
| 62 value->SetInteger("rect_id", rect_id); | 60 value->SetInteger("rect_id", rect_id); |
| 63 value->BeginArray("events"); | 61 value->BeginArray("events"); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}," | 286 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}," |
| 289 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," | 287 "{\"end_time\":220,\"frame_id\":1,\"timestamp\":200}],\"rect_id\":3}," |
| 290 "{\"events\":[" | 288 "{\"events\":[" |
| 291 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" | 289 "{\"end_time\":110,\"frame_id\":3,\"timestamp\":100}],\"rect_id\":4}" |
| 292 "]}", | 290 "]}", |
| 293 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); | 291 MainFrameToString(tracker->GroupMainFrameCountsByRectId())); |
| 294 } | 292 } |
| 295 | 293 |
| 296 } // namespace | 294 } // namespace |
| 297 } // namespace cc | 295 } // namespace cc |
| OLD | NEW |