OLD | NEW |
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/fileapi/test_mount_point_provider.h" | 5 #include "webkit/fileapi/test_mount_point_provider.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 usage_ += delta; | 59 usage_ += delta; |
60 } | 60 } |
61 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE {} | 61 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE {} |
62 | 62 |
63 private: | 63 private: |
64 int64 usage_; | 64 int64 usage_; |
65 }; | 65 }; |
66 | 66 |
67 TestMountPointProvider::TestMountPointProvider( | 67 TestMountPointProvider::TestMountPointProvider( |
68 base::SequencedTaskRunner* task_runner, | 68 base::SequencedTaskRunner* task_runner, |
69 const FilePath& base_path) | 69 const base::FilePath& base_path) |
70 : base_path_(base_path), | 70 : base_path_(base_path), |
71 task_runner_(task_runner), | 71 task_runner_(task_runner), |
72 local_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())), | 72 local_file_util_(new AsyncFileUtilAdapter(new LocalFileUtil())), |
73 quota_util_(new QuotaUtil) { | 73 quota_util_(new QuotaUtil) { |
74 UpdateObserverList::Source source; | 74 UpdateObserverList::Source source; |
75 source.AddObserver(quota_util_.get(), task_runner_); | 75 source.AddObserver(quota_util_.get(), task_runner_); |
76 observers_ = UpdateObserverList(source); | 76 observers_ = UpdateObserverList(source); |
77 } | 77 } |
78 | 78 |
79 TestMountPointProvider::~TestMountPointProvider() { | 79 TestMountPointProvider::~TestMountPointProvider() { |
80 } | 80 } |
81 | 81 |
82 void TestMountPointProvider::ValidateFileSystemRoot( | 82 void TestMountPointProvider::ValidateFileSystemRoot( |
83 const GURL& origin_url, | 83 const GURL& origin_url, |
84 FileSystemType type, | 84 FileSystemType type, |
85 bool create, | 85 bool create, |
86 const ValidateFileSystemCallback& callback) { | 86 const ValidateFileSystemCallback& callback) { |
87 // This won't be called unless we add test code that opens a test | 87 // This won't be called unless we add test code that opens a test |
88 // filesystem by OpenFileSystem. | 88 // filesystem by OpenFileSystem. |
89 NOTREACHED(); | 89 NOTREACHED(); |
90 } | 90 } |
91 | 91 |
92 FilePath TestMountPointProvider::GetFileSystemRootPathOnFileThread( | 92 base::FilePath TestMountPointProvider::GetFileSystemRootPathOnFileThread( |
93 const FileSystemURL& url, | 93 const FileSystemURL& url, |
94 bool create) { | 94 bool create) { |
95 DCHECK_EQ(kFileSystemTypeTest, url.type()); | 95 DCHECK_EQ(kFileSystemTypeTest, url.type()); |
96 bool success = true; | 96 bool success = true; |
97 if (create) | 97 if (create) |
98 success = file_util::CreateDirectory(base_path_); | 98 success = file_util::CreateDirectory(base_path_); |
99 else | 99 else |
100 success = file_util::DirectoryExists(base_path_); | 100 success = file_util::DirectoryExists(base_path_); |
101 return success ? base_path_ : FilePath(); | 101 return success ? base_path_ : base::FilePath(); |
102 } | 102 } |
103 | 103 |
104 bool TestMountPointProvider::IsAccessAllowed(const FileSystemURL& url) { | 104 bool TestMountPointProvider::IsAccessAllowed(const FileSystemURL& url) { |
105 return url.type() == fileapi::kFileSystemTypeTest; | 105 return url.type() == fileapi::kFileSystemTypeTest; |
106 } | 106 } |
107 | 107 |
108 bool TestMountPointProvider::IsRestrictedFileName( | 108 bool TestMountPointProvider::IsRestrictedFileName( |
109 const FilePath& filename) const { | 109 const base::FilePath& filename) const { |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 FileSystemFileUtil* TestMountPointProvider::GetFileUtil(FileSystemType type) { | 113 FileSystemFileUtil* TestMountPointProvider::GetFileUtil(FileSystemType type) { |
114 DCHECK(local_file_util_.get()); | 114 DCHECK(local_file_util_.get()); |
115 return local_file_util_->sync_file_util(); | 115 return local_file_util_->sync_file_util(); |
116 } | 116 } |
117 | 117 |
118 AsyncFileUtil* TestMountPointProvider::GetAsyncFileUtil(FileSystemType type) { | 118 AsyncFileUtil* TestMountPointProvider::GetAsyncFileUtil(FileSystemType type) { |
119 return local_file_util_.get(); | 119 return local_file_util_.get(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 NOTREACHED(); | 164 NOTREACHED(); |
165 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 165 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
166 } | 166 } |
167 | 167 |
168 const UpdateObserverList* TestMountPointProvider::GetUpdateObservers( | 168 const UpdateObserverList* TestMountPointProvider::GetUpdateObservers( |
169 FileSystemType type) const { | 169 FileSystemType type) const { |
170 return &observers_; | 170 return &observers_; |
171 } | 171 } |
172 | 172 |
173 } // namespace fileapi | 173 } // namespace fileapi |
OLD | NEW |