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

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

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
(Empty)
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.
4
5 #include "webkit/browser/fileapi/sandbox_isolated_origin_database.h"
6
7 #include "base/file_util.h"
8 #include "base/logging.h"
9 #include "webkit/browser/fileapi/sandbox_origin_database.h"
10
11 namespace fileapi {
12
13 // Special directory name for isolated origin.
14 const base::FilePath::CharType
15 SandboxIsolatedOriginDatabase::kObsoleteOriginDirectory[] =
16 FILE_PATH_LITERAL("iso");
17
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) {
26 }
27
28 SandboxIsolatedOriginDatabase::~SandboxIsolatedOriginDatabase() {
29 }
30
31 bool SandboxIsolatedOriginDatabase::HasOriginPath(
32 const std::string& origin) {
33 return (origin_ == origin);
34 }
35
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;
42 }
43
44 bool SandboxIsolatedOriginDatabase::RemovePathForOrigin(
45 const std::string& origin) {
46 return true;
47 }
48
49 bool SandboxIsolatedOriginDatabase::ListAllOrigins(
50 std::vector<OriginRecord>* origins) {
51 origins->push_back(OriginRecord(origin_, origin_directory_));
52 return true;
53 }
54
55 void SandboxIsolatedOriginDatabase::DropDatabase() {
56 }
57
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);
64
65 if (database->HasOriginPath(origin)) {
66 // Don't bother.
67 base::DeleteFile(isolated_directory, true /* recursive */);
68 return;
69 }
70
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);
77 }
78 }
79
80 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_isolated_origin_database.h ('k') | webkit/browser/fileapi/sandbox_origin_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698