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

Side by Side Diff: webkit/browser/fileapi/sandbox_origin_database.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months 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 "webkit/browser/fileapi/sandbox_origin_database.h" 5 #include "webkit/browser/fileapi/sandbox_origin_database.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (RepairDatabase(path)) { 101 if (RepairDatabase(path)) {
102 UMA_HISTOGRAM_ENUMERATION(kDatabaseRepairHistogramLabel, 102 UMA_HISTOGRAM_ENUMERATION(kDatabaseRepairHistogramLabel,
103 DB_REPAIR_SUCCEEDED, DB_REPAIR_MAX); 103 DB_REPAIR_SUCCEEDED, DB_REPAIR_MAX);
104 LOG(WARNING) << "Repairing SandboxOriginDatabase completed."; 104 LOG(WARNING) << "Repairing SandboxOriginDatabase completed.";
105 return true; 105 return true;
106 } 106 }
107 UMA_HISTOGRAM_ENUMERATION(kDatabaseRepairHistogramLabel, 107 UMA_HISTOGRAM_ENUMERATION(kDatabaseRepairHistogramLabel,
108 DB_REPAIR_FAILED, DB_REPAIR_MAX); 108 DB_REPAIR_FAILED, DB_REPAIR_MAX);
109 // fall through 109 // fall through
110 case DELETE_ON_CORRUPTION: 110 case DELETE_ON_CORRUPTION:
111 if (!file_util::Delete(file_system_directory_, true)) 111 if (!base::Delete(file_system_directory_, true))
112 return false; 112 return false;
113 if (!file_util::CreateDirectory(file_system_directory_)) 113 if (!file_util::CreateDirectory(file_system_directory_))
114 return false; 114 return false;
115 return Init(init_option, FAIL_ON_CORRUPTION); 115 return Init(init_option, FAIL_ON_CORRUPTION);
116 } 116 }
117 NOTREACHED(); 117 NOTREACHED();
118 return false; 118 return false;
119 } 119 }
120 120
121 bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) { 121 bool SandboxOriginDatabase::RepairDatabase(const std::string& db_path) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 } 160 }
161 } else { 161 } else {
162 directories.erase(dir_itr); 162 directories.erase(dir_itr);
163 } 163 }
164 } 164 }
165 165
166 // Delete any directories not listed in the origins database. 166 // Delete any directories not listed in the origins database.
167 for (std::set<base::FilePath>::iterator dir_itr = directories.begin(); 167 for (std::set<base::FilePath>::iterator dir_itr = directories.begin();
168 dir_itr != directories.end(); 168 dir_itr != directories.end();
169 ++dir_itr) { 169 ++dir_itr) {
170 if (!file_util::Delete(file_system_directory_.Append(*dir_itr), 170 if (!base::Delete(file_system_directory_.Append(*dir_itr),
171 true /* recursive */)) { 171 true /* recursive */)) {
172 DropDatabase(); 172 DropDatabase();
173 return false; 173 return false;
174 } 174 }
175 } 175 }
176 176
177 return true; 177 return true;
178 } 178 }
179 179
180 void SandboxOriginDatabase::HandleError( 180 void SandboxOriginDatabase::HandleError(
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 void SandboxOriginDatabase::DropDatabase() { 294 void SandboxOriginDatabase::DropDatabase() {
295 db_.reset(); 295 db_.reset();
296 } 296 }
297 297
298 base::FilePath SandboxOriginDatabase::GetDatabasePath() const { 298 base::FilePath SandboxOriginDatabase::GetDatabasePath() const {
299 return file_system_directory_.Append(kOriginDatabaseName); 299 return file_system_directory_.Append(kOriginDatabaseName);
300 } 300 }
301 301
302 void SandboxOriginDatabase::RemoveDatabase() { 302 void SandboxOriginDatabase::RemoveDatabase() {
303 DropDatabase(); 303 DropDatabase();
304 file_util::Delete(GetDatabasePath(), true /* recursive */); 304 base::Delete(GetDatabasePath(), true /* recursive */);
305 } 305 }
306 306
307 bool SandboxOriginDatabase::GetLastPathNumber(int* number) { 307 bool SandboxOriginDatabase::GetLastPathNumber(int* number) {
308 DCHECK(db_); 308 DCHECK(db_);
309 DCHECK(number); 309 DCHECK(number);
310 std::string number_string; 310 std::string number_string;
311 leveldb::Status status = 311 leveldb::Status status =
312 db_->Get(leveldb::ReadOptions(), LastPathKey(), &number_string); 312 db_->Get(leveldb::ReadOptions(), LastPathKey(), &number_string);
313 if (status.ok()) 313 if (status.ok())
314 return base::StringToInt(number_string, number); 314 return base::StringToInt(number_string, number);
(...skipping 14 matching lines...) Expand all
329 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1")); 329 db_->Put(leveldb::WriteOptions(), LastPathKey(), std::string("-1"));
330 if (!status.ok()) { 330 if (!status.ok()) {
331 HandleError(FROM_HERE, status); 331 HandleError(FROM_HERE, status);
332 return false; 332 return false;
333 } 333 }
334 *number = -1; 334 *number = -1;
335 return true; 335 return true;
336 } 336 }
337 337
338 } // namespace fileapi 338 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_isolated_origin_database.cc ('k') | webkit/plugins/npapi/plugin_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698