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

Side by Side Diff: chrome/browser/performance_monitor/database.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 // Static 88 // Static
89 scoped_ptr<Database> Database::Create(base::FilePath path) { 89 scoped_ptr<Database> Database::Create(base::FilePath path) {
90 CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 90 CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
91 if (path.empty()) { 91 if (path.empty()) {
92 CHECK(PathService::Get(chrome::DIR_USER_DATA, &path)); 92 CHECK(PathService::Get(chrome::DIR_USER_DATA, &path));
93 path = path.AppendASCII(kDbDir); 93 path = path.AppendASCII(kDbDir);
94 } 94 }
95 scoped_ptr<Database> database; 95 scoped_ptr<Database> database;
96 if (!base::DirectoryExists(path) && !file_util::CreateDirectory(path)) 96 if (!base::DirectoryExists(path) && !base::CreateDirectory(path))
97 return database.Pass(); 97 return database.Pass();
98 database.reset(new Database(path)); 98 database.reset(new Database(path));
99 99
100 // If the database did not initialize correctly, return a NULL scoped_ptr. 100 // If the database did not initialize correctly, return a NULL scoped_ptr.
101 if (!database->valid_) 101 if (!database->valid_)
102 database.reset(); 102 database.reset();
103 return database.Pass(); 103 return database.Pass();
104 } 104 }
105 105
106 bool Database::AddStateValue(const std::string& key, const std::string& value) { 106 bool Database::AddStateValue(const std::string& key, const std::string& value) {
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698