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 "content/public/test/test_file_system_backend.h" | 5 #include "content/public/test/test_file_system_backend.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 class TestFileUtil : public storage::LocalFileUtil { | 41 class TestFileUtil : public storage::LocalFileUtil { |
42 public: | 42 public: |
43 explicit TestFileUtil(const base::FilePath& base_path) | 43 explicit TestFileUtil(const base::FilePath& base_path) |
44 : base_path_(base_path) {} | 44 : base_path_(base_path) {} |
45 virtual ~TestFileUtil() {} | 45 virtual ~TestFileUtil() {} |
46 | 46 |
47 // LocalFileUtil overrides. | 47 // LocalFileUtil overrides. |
48 virtual base::File::Error GetLocalFilePath( | 48 virtual base::File::Error GetLocalFilePath( |
49 FileSystemOperationContext* context, | 49 FileSystemOperationContext* context, |
50 const FileSystemURL& file_system_url, | 50 const FileSystemURL& file_system_url, |
51 base::FilePath* local_file_path) OVERRIDE { | 51 base::FilePath* local_file_path) override { |
52 *local_file_path = base_path_.Append(file_system_url.path()); | 52 *local_file_path = base_path_.Append(file_system_url.path()); |
53 return base::File::FILE_OK; | 53 return base::File::FILE_OK; |
54 } | 54 } |
55 | 55 |
56 private: | 56 private: |
57 base::FilePath base_path_; | 57 base::FilePath base_path_; |
58 }; | 58 }; |
59 | 59 |
60 // Stub implementation of storage::WatcherManager. Emits a fake notification | 60 // Stub implementation of storage::WatcherManager. Emits a fake notification |
61 // after a directory watcher is set successfully. | 61 // after a directory watcher is set successfully. |
62 class TestWatcherManager : public storage::WatcherManager { | 62 class TestWatcherManager : public storage::WatcherManager { |
63 public: | 63 public: |
64 TestWatcherManager() : weak_ptr_factory_(this) {} | 64 TestWatcherManager() : weak_ptr_factory_(this) {} |
65 virtual ~TestWatcherManager() {} | 65 virtual ~TestWatcherManager() {} |
66 | 66 |
67 // storage::WatcherManager overrides. | 67 // storage::WatcherManager overrides. |
68 virtual void AddObserver(Observer* observer) OVERRIDE { | 68 virtual void AddObserver(Observer* observer) override { |
69 observers_.AddObserver(observer); | 69 observers_.AddObserver(observer); |
70 } | 70 } |
71 | 71 |
72 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 72 virtual void RemoveObserver(Observer* observer) override { |
73 observers_.RemoveObserver(observer); | 73 observers_.RemoveObserver(observer); |
74 } | 74 } |
75 | 75 |
76 virtual bool HasObserver(Observer* observer) const OVERRIDE { | 76 virtual bool HasObserver(Observer* observer) const override { |
77 return observers_.HasObserver(observer); | 77 return observers_.HasObserver(observer); |
78 } | 78 } |
79 | 79 |
80 virtual void WatchDirectory(const storage::FileSystemURL& url, | 80 virtual void WatchDirectory(const storage::FileSystemURL& url, |
81 bool recursive, | 81 bool recursive, |
82 const StatusCallback& callback) OVERRIDE { | 82 const StatusCallback& callback) override { |
83 if (recursive) { | 83 if (recursive) { |
84 base::ThreadTaskRunnerHandle::Get()->PostTask( | 84 base::ThreadTaskRunnerHandle::Get()->PostTask( |
85 FROM_HERE, | 85 FROM_HERE, |
86 base::Bind(callback, base::File::FILE_ERROR_INVALID_OPERATION)); | 86 base::Bind(callback, base::File::FILE_ERROR_INVALID_OPERATION)); |
87 return; | 87 return; |
88 } | 88 } |
89 | 89 |
90 const GURL gurl = url.ToGURL(); | 90 const GURL gurl = url.ToGURL(); |
91 if (watched_urls_.find(gurl) != watched_urls_.end()) { | 91 if (watched_urls_.find(gurl) != watched_urls_.end()) { |
92 base::ThreadTaskRunnerHandle::Get()->PostTask( | 92 base::ThreadTaskRunnerHandle::Get()->PostTask( |
(...skipping 14 matching lines...) Expand all Loading... |
107 | 107 |
108 // Send a fake removed notification. | 108 // Send a fake removed notification. |
109 base::ThreadTaskRunnerHandle::Get()->PostTask( | 109 base::ThreadTaskRunnerHandle::Get()->PostTask( |
110 FROM_HERE, | 110 FROM_HERE, |
111 base::Bind(&TestWatcherManager::SendFakeRemoveNotification, | 111 base::Bind(&TestWatcherManager::SendFakeRemoveNotification, |
112 weak_ptr_factory_.GetWeakPtr(), | 112 weak_ptr_factory_.GetWeakPtr(), |
113 url)); | 113 url)); |
114 } | 114 } |
115 | 115 |
116 virtual void UnwatchEntry(const storage::FileSystemURL& url, | 116 virtual void UnwatchEntry(const storage::FileSystemURL& url, |
117 const StatusCallback& callback) OVERRIDE { | 117 const StatusCallback& callback) override { |
118 const GURL gurl = url.ToGURL(); | 118 const GURL gurl = url.ToGURL(); |
119 if (watched_urls_.find(gurl) == watched_urls_.end()) { | 119 if (watched_urls_.find(gurl) == watched_urls_.end()) { |
120 base::ThreadTaskRunnerHandle::Get()->PostTask( | 120 base::ThreadTaskRunnerHandle::Get()->PostTask( |
121 FROM_HERE, base::Bind(callback, base::File::FILE_ERROR_NOT_FOUND)); | 121 FROM_HERE, base::Bind(callback, base::File::FILE_ERROR_NOT_FOUND)); |
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 watched_urls_.erase(gurl); | 125 watched_urls_.erase(gurl); |
126 base::ThreadTaskRunnerHandle::Get()->PostTask( | 126 base::ThreadTaskRunnerHandle::Get()->PostTask( |
127 FROM_HERE, base::Bind(callback, base::File::FILE_OK)); | 127 FROM_HERE, base::Bind(callback, base::File::FILE_OK)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 public storage::FileUpdateObserver { | 159 public storage::FileUpdateObserver { |
160 public: | 160 public: |
161 QuotaUtil() : usage_(0) {} | 161 QuotaUtil() : usage_(0) {} |
162 virtual ~QuotaUtil() {} | 162 virtual ~QuotaUtil() {} |
163 | 163 |
164 // FileSystemQuotaUtil overrides. | 164 // FileSystemQuotaUtil overrides. |
165 virtual base::File::Error DeleteOriginDataOnFileTaskRunner( | 165 virtual base::File::Error DeleteOriginDataOnFileTaskRunner( |
166 FileSystemContext* context, | 166 FileSystemContext* context, |
167 storage::QuotaManagerProxy* proxy, | 167 storage::QuotaManagerProxy* proxy, |
168 const GURL& origin_url, | 168 const GURL& origin_url, |
169 storage::FileSystemType type) OVERRIDE { | 169 storage::FileSystemType type) override { |
170 NOTREACHED(); | 170 NOTREACHED(); |
171 return base::File::FILE_OK; | 171 return base::File::FILE_OK; |
172 } | 172 } |
173 | 173 |
174 virtual scoped_refptr<storage::QuotaReservation> | 174 virtual scoped_refptr<storage::QuotaReservation> |
175 CreateQuotaReservationOnFileTaskRunner( | 175 CreateQuotaReservationOnFileTaskRunner( |
176 const GURL& origin_url, | 176 const GURL& origin_url, |
177 storage::FileSystemType type) OVERRIDE { | 177 storage::FileSystemType type) override { |
178 NOTREACHED(); | 178 NOTREACHED(); |
179 return scoped_refptr<storage::QuotaReservation>(); | 179 return scoped_refptr<storage::QuotaReservation>(); |
180 } | 180 } |
181 | 181 |
182 virtual void GetOriginsForTypeOnFileTaskRunner( | 182 virtual void GetOriginsForTypeOnFileTaskRunner( |
183 storage::FileSystemType type, | 183 storage::FileSystemType type, |
184 std::set<GURL>* origins) OVERRIDE { | 184 std::set<GURL>* origins) override { |
185 NOTREACHED(); | 185 NOTREACHED(); |
186 } | 186 } |
187 | 187 |
188 virtual void GetOriginsForHostOnFileTaskRunner( | 188 virtual void GetOriginsForHostOnFileTaskRunner( |
189 storage::FileSystemType type, | 189 storage::FileSystemType type, |
190 const std::string& host, | 190 const std::string& host, |
191 std::set<GURL>* origins) OVERRIDE { | 191 std::set<GURL>* origins) override { |
192 NOTREACHED(); | 192 NOTREACHED(); |
193 } | 193 } |
194 | 194 |
195 virtual int64 GetOriginUsageOnFileTaskRunner( | 195 virtual int64 GetOriginUsageOnFileTaskRunner( |
196 FileSystemContext* context, | 196 FileSystemContext* context, |
197 const GURL& origin_url, | 197 const GURL& origin_url, |
198 storage::FileSystemType type) OVERRIDE { | 198 storage::FileSystemType type) override { |
199 return usage_; | 199 return usage_; |
200 } | 200 } |
201 | 201 |
202 // FileUpdateObserver overrides. | 202 // FileUpdateObserver overrides. |
203 virtual void OnStartUpdate(const FileSystemURL& url) OVERRIDE {} | 203 virtual void OnStartUpdate(const FileSystemURL& url) override {} |
204 virtual void OnUpdate(const FileSystemURL& url, int64 delta) OVERRIDE { | 204 virtual void OnUpdate(const FileSystemURL& url, int64 delta) override { |
205 usage_ += delta; | 205 usage_ += delta; |
206 } | 206 } |
207 virtual void OnEndUpdate(const FileSystemURL& url) OVERRIDE {} | 207 virtual void OnEndUpdate(const FileSystemURL& url) override {} |
208 | 208 |
209 private: | 209 private: |
210 int64 usage_; | 210 int64 usage_; |
211 DISALLOW_COPY_AND_ASSIGN(QuotaUtil); | 211 DISALLOW_COPY_AND_ASSIGN(QuotaUtil); |
212 }; | 212 }; |
213 | 213 |
214 TestFileSystemBackend::TestFileSystemBackend( | 214 TestFileSystemBackend::TestFileSystemBackend( |
215 base::SequencedTaskRunner* task_runner, | 215 base::SequencedTaskRunner* task_runner, |
216 const base::FilePath& base_path) | 216 const base::FilePath& base_path) |
217 : base_path_(base_path), | 217 : base_path_(base_path), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return NULL; | 335 return NULL; |
336 } | 336 } |
337 | 337 |
338 void TestFileSystemBackend::AddFileChangeObserver( | 338 void TestFileSystemBackend::AddFileChangeObserver( |
339 storage::FileChangeObserver* observer) { | 339 storage::FileChangeObserver* observer) { |
340 change_observers_ = | 340 change_observers_ = |
341 change_observers_.AddObserver(observer, task_runner_.get()); | 341 change_observers_.AddObserver(observer, task_runner_.get()); |
342 } | 342 } |
343 | 343 |
344 } // namespace content | 344 } // namespace content |
OLD | NEW |