net cleanup: Remove unnecessary namespace prefixes.
[chromium-blink-merge.git] / storage / browser / fileapi / sandbox_isolated_origin_database.cc
blob3e3c21803308382f18a17572b646ee4684ba5881
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "storage/browser/fileapi/sandbox_isolated_origin_database.h"
7 #include "base/files/file_util.h"
8 #include "base/logging.h"
9 #include "storage/browser/fileapi/sandbox_origin_database.h"
11 namespace storage {
13 // Special directory name for isolated origin.
14 const base::FilePath::CharType
15 SandboxIsolatedOriginDatabase::kObsoleteOriginDirectory[] =
16 FILE_PATH_LITERAL("iso");
18 SandboxIsolatedOriginDatabase::SandboxIsolatedOriginDatabase(
19 const std::string& origin,
20 const base::FilePath& file_system_directory,
21 const base::FilePath& origin_directory)
22 : migration_checked_(false),
23 origin_(origin),
24 file_system_directory_(file_system_directory),
25 origin_directory_(origin_directory) {
28 SandboxIsolatedOriginDatabase::~SandboxIsolatedOriginDatabase() {
31 bool SandboxIsolatedOriginDatabase::HasOriginPath(
32 const std::string& origin) {
33 return (origin_ == origin);
36 bool SandboxIsolatedOriginDatabase::GetPathForOrigin(
37 const std::string& origin, base::FilePath* directory) {
38 if (origin != origin_)
39 return false;
40 *directory = origin_directory_;
41 return true;
44 bool SandboxIsolatedOriginDatabase::RemovePathForOrigin(
45 const std::string& origin) {
46 return true;
49 bool SandboxIsolatedOriginDatabase::ListAllOrigins(
50 std::vector<OriginRecord>* origins) {
51 origins->push_back(OriginRecord(origin_, origin_directory_));
52 return true;
55 void SandboxIsolatedOriginDatabase::DropDatabase() {
58 void SandboxIsolatedOriginDatabase::MigrateBackFromObsoleteOriginDatabase(
59 const std::string& origin,
60 const base::FilePath& file_system_directory,
61 SandboxOriginDatabase* database) {
62 base::FilePath isolated_directory =
63 file_system_directory.Append(kObsoleteOriginDirectory);
65 if (database->HasOriginPath(origin)) {
66 // Don't bother.
67 base::DeleteFile(isolated_directory, true /* recursive */);
68 return;
71 base::FilePath directory_name;
72 if (database->GetPathForOrigin(origin, &directory_name)) {
73 base::FilePath origin_directory =
74 file_system_directory.Append(directory_name);
75 base::DeleteFile(origin_directory, true /* recursive */);
76 base::Move(isolated_directory, origin_directory);
80 } // namespace storage