| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 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 #ifndef CONTENT_BROWSER_FILEAPI_MOCK_FILE_UPDATE_OBSERVER_H_ | |
| 6 #define CONTENT_BROWSER_FILEAPI_MOCK_FILE_UPDATE_OBSERVER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <map> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/macros.h" | |
| 14 #include "storage/browser/fileapi/file_observers.h" | |
| 15 #include "storage/browser/fileapi/file_system_url.h" | |
| 16 #include "storage/browser/fileapi/task_runner_bound_observer_list.h" | |
| 17 | |
| 18 namespace storage { | |
| 19 | |
| 20 // Mock file change observer. | |
| 21 class MockFileUpdateObserver : public FileUpdateObserver { | |
| 22 public: | |
| 23 MockFileUpdateObserver(); | |
| 24 ~MockFileUpdateObserver() override; | |
| 25 | |
| 26 // Creates a ChangeObserverList which only contains given |observer|. | |
| 27 static UpdateObserverList CreateList(MockFileUpdateObserver* observer); | |
| 28 | |
| 29 // FileUpdateObserver overrides. | |
| 30 void OnStartUpdate(const FileSystemURL& url) override; | |
| 31 void OnUpdate(const FileSystemURL& url, int64_t delta) override; | |
| 32 void OnEndUpdate(const FileSystemURL& url) override; | |
| 33 | |
| 34 void Enable() { is_ready_ = true; } | |
| 35 | |
| 36 void Disable() { | |
| 37 start_update_count_.clear(); | |
| 38 end_update_count_.clear(); | |
| 39 is_ready_ = false; | |
| 40 } | |
| 41 | |
| 42 private: | |
| 43 std::map<FileSystemURL, int, FileSystemURL::Comparator> start_update_count_; | |
| 44 std::map<FileSystemURL, int, FileSystemURL::Comparator> end_update_count_; | |
| 45 bool is_ready_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(MockFileUpdateObserver); | |
| 48 }; | |
| 49 | |
| 50 } // namespace storage | |
| 51 | |
| 52 #endif // CONTENT_BROWSER_FILEAPI_MOCK_FILE_UPDATE_OBSERVER_H_ | |
| OLD | NEW |