| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 84 } | 84 } | 
| 85 | 85 | 
| 86 // Static | 86 // Static | 
| 87 scoped_ptr<Database> Database::Create(base::FilePath path) { | 87 scoped_ptr<Database> Database::Create(base::FilePath path) { | 
| 88   CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 88   CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 
| 89   if (path.empty()) { | 89   if (path.empty()) { | 
| 90     CHECK(PathService::Get(chrome::DIR_USER_DATA, &path)); | 90     CHECK(PathService::Get(chrome::DIR_USER_DATA, &path)); | 
| 91     path = path.AppendASCII(kDbDir); | 91     path = path.AppendASCII(kDbDir); | 
| 92   } | 92   } | 
| 93   scoped_ptr<Database> database; | 93   scoped_ptr<Database> database; | 
| 94   if (!file_util::DirectoryExists(path) && !file_util::CreateDirectory(path)) | 94   if (!base::DirectoryExists(path) && !file_util::CreateDirectory(path)) | 
| 95     return database.Pass(); | 95     return database.Pass(); | 
| 96   database.reset(new Database(path)); | 96   database.reset(new Database(path)); | 
| 97 | 97 | 
| 98   // If the database did not initialize correctly, return a NULL scoped_ptr. | 98   // If the database did not initialize correctly, return a NULL scoped_ptr. | 
| 99   if (!database->valid_) | 99   if (!database->valid_) | 
| 100     database.reset(); | 100     database.reset(); | 
| 101   return database.Pass(); | 101   return database.Pass(); | 
| 102 } | 102 } | 
| 103 | 103 | 
| 104 bool Database::AddStateValue(const std::string& key, const std::string& value) { | 104 bool Database::AddStateValue(const std::string& key, const std::string& value) { | 
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 578     start_time_key_ = key_builder_->CreateActiveIntervalKey(current_time); | 578     start_time_key_ = key_builder_->CreateActiveIntervalKey(current_time); | 
| 579     end_time = start_time_key_; | 579     end_time = start_time_key_; | 
| 580   } else { | 580   } else { | 
| 581     end_time = key_builder_->CreateActiveIntervalKey(clock_->GetTime()); | 581     end_time = key_builder_->CreateActiveIntervalKey(clock_->GetTime()); | 
| 582   } | 582   } | 
| 583   last_update_time_ = current_time; | 583   last_update_time_ = current_time; | 
| 584   active_interval_db_->Put(write_options_, start_time_key_, end_time); | 584   active_interval_db_->Put(write_options_, start_time_key_, end_time); | 
| 585 } | 585 } | 
| 586 | 586 | 
| 587 }  // namespace performance_monitor | 587 }  // namespace performance_monitor | 
| OLD | NEW | 
|---|