[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / fileapi / mock_file_change_observer.h
blob92c24e1bc80a17c9f9bffe5d6409517ee36905df
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.
5 #ifndef CONTENT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
6 #define CONTENT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "storage/browser/fileapi/file_observers.h"
11 #include "storage/browser/fileapi/file_system_url.h"
12 #include "storage/browser/fileapi/task_runner_bound_observer_list.h"
14 namespace storage {
16 // Mock file change observer.
17 class MockFileChangeObserver : public FileChangeObserver {
18 public:
19 MockFileChangeObserver();
20 ~MockFileChangeObserver() override;
22 // Creates a ChangeObserverList which only contains given |observer|.
23 static ChangeObserverList CreateList(MockFileChangeObserver* observer);
25 // FileChangeObserver overrides.
26 void OnCreateFile(const FileSystemURL& url) override;
27 void OnCreateFileFrom(const FileSystemURL& url,
28 const FileSystemURL& src) override;
29 void OnRemoveFile(const FileSystemURL& url) override;
30 void OnModifyFile(const FileSystemURL& url) override;
31 void OnCreateDirectory(const FileSystemURL& url) override;
32 void OnRemoveDirectory(const FileSystemURL& url) override;
34 void ResetCount() {
35 create_file_count_ = 0;
36 create_file_from_count_ = 0;
37 remove_file_count_ = 0;
38 modify_file_count_ = 0;
39 create_directory_count_ = 0;
40 remove_directory_count_ = 0;
43 bool HasNoChange() const {
44 return create_file_count_ == 0 &&
45 create_file_from_count_ == 0 &&
46 remove_file_count_ == 0 &&
47 modify_file_count_ == 0 &&
48 create_directory_count_ == 0 &&
49 remove_directory_count_ == 0;
52 int create_file_count() const { return create_file_count_; }
53 int create_file_from_count() const { return create_file_from_count_; }
54 int remove_file_count() const { return remove_file_count_; }
55 int modify_file_count() const { return modify_file_count_; }
56 int create_directory_count() const { return create_directory_count_; }
57 int remove_directory_count() const { return remove_directory_count_; }
59 int get_and_reset_create_file_count() {
60 int tmp = create_file_count_;
61 create_file_count_ = 0;
62 return tmp;
64 int get_and_reset_create_file_from_count() {
65 int tmp = create_file_from_count_;
66 create_file_from_count_ = 0;
67 return tmp;
69 int get_and_reset_remove_file_count() {
70 int tmp = remove_file_count_;
71 remove_file_count_ = 0;
72 return tmp;
74 int get_and_reset_modify_file_count() {
75 int tmp = modify_file_count_;
76 modify_file_count_ = 0;
77 return tmp;
79 int get_and_reset_create_directory_count() {
80 int tmp = create_directory_count_;
81 create_directory_count_ = 0;
82 return tmp;
84 int get_and_reset_remove_directory_count() {
85 int tmp = remove_directory_count_;
86 remove_directory_count_ = 0;
87 return tmp;
90 private:
91 int create_file_count_;
92 int create_file_from_count_;
93 int remove_file_count_;
94 int modify_file_count_;
95 int create_directory_count_;
96 int remove_directory_count_;
98 DISALLOW_COPY_AND_ASSIGN(MockFileChangeObserver);
101 } // namespace storage
103 #endif // CONTENT_BROWSER_FILEAPI_MOCK_FILE_CHANGE_OBSERVER_H_