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

Side by Side Diff: webkit/fileapi/file_system_directory_database.cc

Issue 7042029: Code to migrate a single directory from the old sandbox to the new. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Attempted windows fix. Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/fileapi/file_system_directory_database.h" 5 #include "webkit/fileapi/file_system_directory_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 HandleError(status); 382 HandleError(status);
383 return false; 383 return false;
384 } 384 }
385 // The database must not yet exist; initialize it. 385 // The database must not yet exist; initialize it.
386 if (!StoreDefaultValues()) 386 if (!StoreDefaultValues())
387 return false; 387 return false;
388 388
389 return GetNextInteger(next); 389 return GetNextInteger(next);
390 } 390 }
391 391
392 // static
393 bool FileSystemDirectoryDatabase::DestroyDatabase(const FilePath& path) {
394 std::string name;
395 #if defined(OS_POSIX)
396 name = path.value();
397 #elif defined(OS_WIN)
398 name = base::SysWideToUTF8(path.value());
399 #endif
400 leveldb::Status status = leveldb::DestroyDB(name, leveldb::Options());
401 if (status.ok())
402 return true;
403 LOG(WARNING) << "Failed to destroy a database with status " <<
404 status.ToString();
405 return false;
406 }
407
392 bool FileSystemDirectoryDatabase::Init() { 408 bool FileSystemDirectoryDatabase::Init() {
393 if (db_.get()) 409 if (db_.get())
394 return true; 410 return true;
395 411
396 leveldb::Options options; 412 leveldb::Options options;
397 options.create_if_missing = true; 413 options.create_if_missing = true;
398 leveldb::DB* db; 414 leveldb::DB* db;
399 leveldb::Status status = leveldb::DB::Open(options, path_, &db); 415 leveldb::Status status = leveldb::DB::Open(options, path_, &db);
400 if (status.ok()) { 416 if (status.ok()) {
401 db_.reset(db); 417 db_.reset(db);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 return true; 529 return true;
514 } 530 }
515 531
516 void FileSystemDirectoryDatabase::HandleError(leveldb::Status status) { 532 void FileSystemDirectoryDatabase::HandleError(leveldb::Status status) {
517 LOG(ERROR) << "FileSystemDirectoryDatabase failed with error: " << 533 LOG(ERROR) << "FileSystemDirectoryDatabase failed with error: " <<
518 status.ToString(); 534 status.ToString();
519 db_.reset(); 535 db_.reset();
520 } 536 }
521 537
522 } // namespace fileapi 538 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_directory_database.h ('k') | webkit/fileapi/file_system_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698