| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/performance_monitor/database.h" | 5 #include "chrome/browser/performance_monitor/database.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 double StringToDouble(const std::string& s) { | 50 double StringToDouble(const std::string& s) { |
| 51 double value = 0.0; | 51 double value = 0.0; |
| 52 if (!base::StringToDouble(s, &value)) | 52 if (!base::StringToDouble(s, &value)) |
| 53 LOG(ERROR) << "Failed to convert " << s << " to double."; | 53 LOG(ERROR) << "Failed to convert " << s << " to double."; |
| 54 return value; | 54 return value; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Returns an event from the given JSON string; the scoped_ptr will be NULL if | 57 // Returns an event from the given JSON string; the scoped_ptr will be NULL if |
| 58 // we are unable to properly parse the JSON. | 58 // we are unable to properly parse the JSON. |
| 59 scoped_ptr<Event> EventFromJSON(const std::string& data) { | 59 scoped_ptr<Event> EventFromJSON(const std::string& data) { |
| 60 Value* value = base::JSONReader::Read(data); | 60 base::Value* value = base::JSONReader::Read(data); |
| 61 DictionaryValue* dict = NULL; | 61 base::DictionaryValue* dict = NULL; |
| 62 if (!value || !value->GetAsDictionary(&dict)) | 62 if (!value || !value->GetAsDictionary(&dict)) |
| 63 return scoped_ptr<Event>(); | 63 return scoped_ptr<Event>(); |
| 64 | 64 |
| 65 return Event::FromValue(scoped_ptr<DictionaryValue>(dict)); | 65 return Event::FromValue(scoped_ptr<base::DictionaryValue>(dict)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 const char Database::kDatabaseSequenceToken[] = | 70 const char Database::kDatabaseSequenceToken[] = |
| 71 "_performance_monitor_db_sequence_token_"; | 71 "_performance_monitor_db_sequence_token_"; |
| 72 | 72 |
| 73 TimeRange::TimeRange() { | 73 TimeRange::TimeRange() { |
| 74 } | 74 } |
| 75 | 75 |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 start_time_key_ = key_builder_->CreateActiveIntervalKey(current_time); | 581 start_time_key_ = key_builder_->CreateActiveIntervalKey(current_time); |
| 582 end_time = start_time_key_; | 582 end_time = start_time_key_; |
| 583 } else { | 583 } else { |
| 584 end_time = key_builder_->CreateActiveIntervalKey(clock_->GetTime()); | 584 end_time = key_builder_->CreateActiveIntervalKey(clock_->GetTime()); |
| 585 } | 585 } |
| 586 last_update_time_ = current_time; | 586 last_update_time_ = current_time; |
| 587 active_interval_db_->Put(write_options_, start_time_key_, end_time); | 587 active_interval_db_->Put(write_options_, start_time_key_, end_time); |
| 588 } | 588 } |
| 589 | 589 |
| 590 } // namespace performance_monitor | 590 } // namespace performance_monitor |
| OLD | NEW |