OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "storage/browser/fileapi/sandbox_prioritized_origin_database.h" | 5 #include "storage/browser/fileapi/sandbox_prioritized_origin_database.h" |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | |
9 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
11 #include "base/pickle.h" | 10 #include "base/pickle.h" |
12 #include "storage/browser/fileapi/sandbox_isolated_origin_database.h" | 11 #include "storage/browser/fileapi/sandbox_isolated_origin_database.h" |
13 #include "storage/browser/fileapi/sandbox_origin_database.h" | 12 #include "storage/browser/fileapi/sandbox_origin_database.h" |
14 | 13 |
15 namespace storage { | 14 namespace storage { |
16 | 15 |
| 16 const base::FilePath::CharType* |
| 17 SandboxPrioritizedOriginDatabase::kPrimaryDirectory = |
| 18 FILE_PATH_LITERAL("primary"); |
| 19 |
| 20 const base::FilePath::CharType* |
| 21 SandboxPrioritizedOriginDatabase::kPrimaryOriginFile = |
| 22 FILE_PATH_LITERAL("primary.origin"); |
| 23 |
17 namespace { | 24 namespace { |
18 | 25 |
19 const base::FilePath::CharType kPrimaryDirectory[] = | |
20 FILE_PATH_LITERAL("primary"); | |
21 const base::FilePath::CharType kPrimaryOriginFile[] = | |
22 FILE_PATH_LITERAL("primary.origin"); | |
23 | |
24 bool WritePrimaryOriginFile(const base::FilePath& path, | 26 bool WritePrimaryOriginFile(const base::FilePath& path, |
25 const std::string& origin) { | 27 const std::string& origin) { |
26 base::File file(path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE); | 28 base::File file(path, base::File::FLAG_OPEN_ALWAYS | base::File::FLAG_WRITE); |
27 if (!file.IsValid()) | 29 if (!file.IsValid()) |
28 return false; | 30 return false; |
29 if (!file.created()) | 31 if (!file.created()) |
30 file.SetLength(0); | 32 file.SetLength(0); |
31 Pickle pickle; | 33 Pickle pickle; |
32 pickle.WriteString(origin); | 34 pickle.WriteString(origin); |
33 file.Write(0, static_cast<const char*>(pickle.data()), pickle.size()); | 35 file.Write(0, static_cast<const char*>(pickle.data()), pickle.size()); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 216 } |
215 } | 217 } |
216 | 218 |
217 SandboxOriginDatabase* | 219 SandboxOriginDatabase* |
218 SandboxPrioritizedOriginDatabase::GetSandboxOriginDatabase() { | 220 SandboxPrioritizedOriginDatabase::GetSandboxOriginDatabase() { |
219 MaybeInitializeNonPrimaryDatabase(true); | 221 MaybeInitializeNonPrimaryDatabase(true); |
220 return origin_database_.get(); | 222 return origin_database_.get(); |
221 } | 223 } |
222 | 224 |
223 } // namespace storage | 225 } // namespace storage |
OLD | NEW |