| OLD | NEW |
| 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 "content/renderer/stats_collection_controller.h" | 5 #include "content/renderer/stats_collection_controller.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/metrics/statistics_recorder.h" | 10 #include "base/metrics/statistics_recorder.h" |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "content/common/child_process_messages.h" | 12 #include "content/common/child_process_messages.h" |
| 12 #include "content/renderer/render_view_impl.h" | 13 #include "content/renderer/render_view_impl.h" |
| 13 #include "gin/handle.h" | 14 #include "gin/handle.h" |
| 14 #include "gin/object_template_builder.h" | 15 #include "gin/object_template_builder.h" |
| 15 #include "third_party/WebKit/public/web/WebKit.h" | 16 #include "third_party/WebKit/public/web/WebKit.h" |
| 16 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 17 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 17 #include "third_party/WebKit/public/web/WebView.h" | 18 #include "third_party/WebKit/public/web/WebView.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 48 // {'load_start_ms': 1, 'load_duration_ms': 2.5} | 49 // {'load_start_ms': 1, 'load_duration_ms': 2.5} |
| 49 // either value may be null if a web contents hasn't fully loaded. | 50 // either value may be null if a web contents hasn't fully loaded. |
| 50 // load_start_ms is represented as milliseconds since the unix epoch. | 51 // load_start_ms is represented as milliseconds since the unix epoch. |
| 51 void ConvertLoadTimeToJSON( | 52 void ConvertLoadTimeToJSON( |
| 52 const base::Time& load_start_time, | 53 const base::Time& load_start_time, |
| 53 const base::Time& load_stop_time, | 54 const base::Time& load_stop_time, |
| 54 std::string *result) { | 55 std::string *result) { |
| 55 base::DictionaryValue item; | 56 base::DictionaryValue item; |
| 56 | 57 |
| 57 if (load_start_time.is_null()) { | 58 if (load_start_time.is_null()) { |
| 58 item.Set("load_start_ms", base::Value::CreateNullValue()); | 59 item.Set("load_start_ms", base::MakeUnique<base::Value>()); |
| 59 } else { | 60 } else { |
| 60 item.SetDouble("load_start_ms", (load_start_time - base::Time::UnixEpoch()) | 61 item.SetDouble("load_start_ms", (load_start_time - base::Time::UnixEpoch()) |
| 61 .InMillisecondsF()); | 62 .InMillisecondsF()); |
| 62 } | 63 } |
| 63 if (load_start_time.is_null() || load_stop_time.is_null()) { | 64 if (load_start_time.is_null() || load_stop_time.is_null()) { |
| 64 item.Set("load_duration_ms", base::Value::CreateNullValue()); | 65 item.Set("load_duration_ms", base::MakeUnique<base::Value>()); |
| 65 } else { | 66 } else { |
| 66 item.SetDouble("load_duration_ms", | 67 item.SetDouble("load_duration_ms", |
| 67 (load_stop_time - load_start_time).InMillisecondsF()); | 68 (load_stop_time - load_start_time).InMillisecondsF()); |
| 68 } | 69 } |
| 69 base::JSONWriter::Write(item, result); | 70 base::JSONWriter::Write(item, result); |
| 70 } | 71 } |
| 71 | 72 |
| 72 } // namespace | 73 } // namespace |
| 73 | 74 |
| 74 // static | 75 // static |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 152 } |
| 152 | 153 |
| 153 std::string tab_timing_json; | 154 std::string tab_timing_json; |
| 154 ConvertLoadTimeToJSON( | 155 ConvertLoadTimeToJSON( |
| 155 observer->load_start_time(), observer->load_stop_time(), | 156 observer->load_start_time(), observer->load_stop_time(), |
| 156 &tab_timing_json); | 157 &tab_timing_json); |
| 157 return tab_timing_json; | 158 return tab_timing_json; |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace content | 161 } // namespace content |
| OLD | NEW |