Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(621)

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h

Issue 2704123007: mediaview: Fix ARC file system operation deferring. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_H_
6 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_H_ 6 #define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 // Creates an instance suitable for unit tests. 60 // Creates an instance suitable for unit tests.
61 // This instance will run all operations immediately without deferring by 61 // This instance will run all operations immediately without deferring by
62 // default. Also, deferring can be enabled/disabled by calling 62 // default. Also, deferring can be enabled/disabled by calling
63 // SetShouldDefer() from friend classes. 63 // SetShouldDefer() from friend classes.
64 static std::unique_ptr<ArcFileSystemOperationRunner> CreateForTesting( 64 static std::unique_ptr<ArcFileSystemOperationRunner> CreateForTesting(
65 ArcBridgeService* bridge_service); 65 ArcBridgeService* bridge_service);
66 66
67 // The standard constructor. A production instance should be created by 67 // The standard constructor. A production instance should be created by
68 // this constructor. 68 // this constructor.
69 explicit ArcFileSystemOperationRunner(ArcBridgeService* bridge_service); 69 ArcFileSystemOperationRunner(ArcBridgeService* bridge_service,
70 const Profile* profile);
70 ~ArcFileSystemOperationRunner() override; 71 ~ArcFileSystemOperationRunner() override;
71 72
72 // Runs file system operations. See file_system.mojom for documentation. 73 // Runs file system operations. See file_system.mojom for documentation.
73 void GetFileSize(const GURL& url, const GetFileSizeCallback& callback); 74 void GetFileSize(const GURL& url, const GetFileSizeCallback& callback);
74 void OpenFileToRead(const GURL& url, const OpenFileToReadCallback& callback); 75 void OpenFileToRead(const GURL& url, const OpenFileToReadCallback& callback);
75 void GetDocument(const std::string& authority, 76 void GetDocument(const std::string& authority,
76 const std::string& document_id, 77 const std::string& document_id,
77 const GetDocumentCallback& callback); 78 const GetDocumentCallback& callback);
78 void GetChildDocuments(const std::string& authority, 79 void GetChildDocuments(const std::string& authority,
79 const std::string& parent_document_id, 80 const std::string& parent_document_id,
80 const GetChildDocumentsCallback& callback); 81 const GetChildDocumentsCallback& callback);
81 82
82 // ArcSessionManager::Observer overrides: 83 // ArcSessionManager::Observer overrides:
83 void OnArcPlayStoreEnabledChanged(bool enabled) override; 84 void OnArcPlayStoreEnabledChanged(bool enabled) override;
84 85
85 // InstanceHolder<mojom::FileSystemInstance>::Observer overrides: 86 // InstanceHolder<mojom::FileSystemInstance>::Observer overrides:
86 void OnInstanceReady() override; 87 void OnInstanceReady() override;
87 void OnInstanceClosed() override; 88 void OnInstanceClosed() override;
88 89
89 private: 90 private:
90 friend class ArcFileSystemOperationRunnerTest; 91 friend class ArcFileSystemOperationRunnerTest;
91 92
92 ArcFileSystemOperationRunner(ArcBridgeService* bridge_service, 93 ArcFileSystemOperationRunner(ArcBridgeService* bridge_service,
94 const Profile* profile,
93 bool observe_events); 95 bool observe_events);
94 96
95 // Called whenever ARC states related to |should_defer_| are changed. 97 // Called whenever ARC states related to |should_defer_| are changed.
96 void OnStateChanged(); 98 void OnStateChanged();
97 99
98 // Enables/disables deferring. 100 // Enables/disables deferring.
99 // Friend unit tests can call this function to simulate enabling/disabling 101 // Friend unit tests can call this function to simulate enabling/disabling
100 // deferring. 102 // deferring.
101 void SetShouldDefer(bool should_defer); 103 void SetShouldDefer(bool should_defer);
102 104
105 // Profile this runner is associated with.
hidehiko 2017/02/23 08:36:04 Could you note that this can be null for testing?
Shuhei Takahashi 2017/02/23 08:49:30 Done.
106 const Profile* profile_;
hidehiko 2017/02/23 08:36:04 const Profile* const profile_; In ARC, it is enco
Shuhei Takahashi 2017/02/23 08:49:30 I agree we want more const :) Also changed observe
107
103 // Indicates if this instance should register observers to receive events. 108 // Indicates if this instance should register observers to receive events.
104 // Usually true, but set to false in unit tests. 109 // Usually true, but set to false in unit tests.
105 bool observe_events_; 110 bool observe_events_;
106 111
107 // Set to true if operations should be deferred at this moment. 112 // Set to true if operations should be deferred at this moment.
108 // The default is set to false so that operations are not deferred in 113 // The default is set to false so that operations are not deferred in
109 // unit tests. 114 // unit tests.
110 bool should_defer_ = false; 115 bool should_defer_ = false;
111 116
112 // List of deferred operations. 117 // List of deferred operations.
113 std::vector<base::Closure> deferred_operations_; 118 std::vector<base::Closure> deferred_operations_;
114 119
115 base::WeakPtrFactory<ArcFileSystemOperationRunner> weak_ptr_factory_; 120 base::WeakPtrFactory<ArcFileSystemOperationRunner> weak_ptr_factory_;
116 121
117 DISALLOW_COPY_AND_ASSIGN(ArcFileSystemOperationRunner); 122 DISALLOW_COPY_AND_ASSIGN(ArcFileSystemOperationRunner);
118 }; 123 };
119 124
120 } // namespace arc 125 } // namespace arc
121 126
122 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_ H_ 127 #endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_FILE_SYSTEM_OPERATION_RUNNER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698