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

Side by Side Diff: chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_util.cc

Issue 2715493002: mediaview: Support watchers in ArcFileSystemOperationRunner. (Closed)
Patch Set: Review ready. 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_u til.h" 5 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner_u til.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h "
11 #include "components/arc/arc_service_manager.h" 10 #include "components/arc/arc_service_manager.h"
12 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
13 #include "url/gurl.h" 12 #include "url/gurl.h"
14 13
15 using content::BrowserThread; 14 using content::BrowserThread;
16 15
17 namespace arc { 16 namespace arc {
18 17
19 namespace file_system_operation_runner_util { 18 namespace file_system_operation_runner_util {
20 19
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 DCHECK_CURRENTLY_ON(BrowserThread::UI); 69 DCHECK_CURRENTLY_ON(BrowserThread::UI);
71 auto* runner = 70 auto* runner =
72 ArcServiceManager::GetGlobalService<ArcFileSystemOperationRunner>(); 71 ArcServiceManager::GetGlobalService<ArcFileSystemOperationRunner>();
73 if (!runner) { 72 if (!runner) {
74 callback.Run(base::nullopt); 73 callback.Run(base::nullopt);
75 return; 74 return;
76 } 75 }
77 runner->GetChildDocuments(authority, parent_document_id, callback); 76 runner->GetChildDocuments(authority, parent_document_id, callback);
78 } 77 }
79 78
79 void AddWatcherOnUIThread(const std::string& authority,
80 const std::string& document_id,
81 const WatcherCallback& watcher_callback,
82 const AddWatcherCallback& callback) {
83 DCHECK_CURRENTLY_ON(BrowserThread::UI);
84 auto* runner =
85 ArcServiceManager::GetGlobalService<ArcFileSystemOperationRunner>();
86 if (!runner) {
87 callback.Run(-1);
88 return;
89 }
90 runner->AddWatcher(authority, document_id, watcher_callback, callback);
91 }
92
93 void RemoveWatcherOnUIThread(int64_t watcher_id,
94 const RemoveWatcherCallback& callback) {
95 DCHECK_CURRENTLY_ON(BrowserThread::UI);
96 auto* runner =
97 ArcServiceManager::GetGlobalService<ArcFileSystemOperationRunner>();
98 if (!runner) {
99 callback.Run(false);
100 return;
101 }
102 runner->RemoveWatcher(watcher_id, callback);
103 }
104
80 } // namespace 105 } // namespace
81 106
82 void GetFileSizeOnIOThread(const GURL& url, 107 void GetFileSizeOnIOThread(const GURL& url,
83 const GetFileSizeCallback& callback) { 108 const GetFileSizeCallback& callback) {
84 DCHECK_CURRENTLY_ON(BrowserThread::IO); 109 DCHECK_CURRENTLY_ON(BrowserThread::IO);
85 BrowserThread::PostTask( 110 BrowserThread::PostTask(
86 BrowserThread::UI, FROM_HERE, 111 BrowserThread::UI, FROM_HERE,
87 base::Bind(&GetFileSizeOnUIThread, url, 112 base::Bind(&GetFileSizeOnUIThread, url,
88 base::Bind(&PostToIOThread<int64_t>, callback))); 113 base::Bind(&PostToIOThread<int64_t>, callback)));
89 } 114 }
(...skipping 23 matching lines...) Expand all
113 DCHECK_CURRENTLY_ON(BrowserThread::IO); 138 DCHECK_CURRENTLY_ON(BrowserThread::IO);
114 BrowserThread::PostTask( 139 BrowserThread::PostTask(
115 BrowserThread::UI, FROM_HERE, 140 BrowserThread::UI, FROM_HERE,
116 base::Bind( 141 base::Bind(
117 &GetChildDocumentsOnUIThread, authority, parent_document_id, 142 &GetChildDocumentsOnUIThread, authority, parent_document_id,
118 base::Bind( 143 base::Bind(
119 &PostToIOThread<base::Optional<std::vector<mojom::DocumentPtr>>>, 144 &PostToIOThread<base::Optional<std::vector<mojom::DocumentPtr>>>,
120 callback))); 145 callback)));
121 } 146 }
122 147
148 void AddWatcherOnIOThread(const std::string& authority,
149 const std::string& document_id,
150 const WatcherCallback& watcher_callback,
151 const AddWatcherCallback& callback) {
152 DCHECK_CURRENTLY_ON(BrowserThread::IO);
153 BrowserThread::PostTask(
154 BrowserThread::UI, FROM_HERE,
155 base::Bind(
156 &AddWatcherOnUIThread, authority, document_id,
157 base::Bind(&PostToIOThread<ArcFileSystemOperationRunner::ChangeType>,
158 watcher_callback),
159 base::Bind(&PostToIOThread<int64_t>, callback)));
160 }
161
162 void RemoveWatcherOnIOThread(int64_t watcher_id,
163 const RemoveWatcherCallback& callback) {
164 DCHECK_CURRENTLY_ON(BrowserThread::IO);
165 BrowserThread::PostTask(
166 BrowserThread::UI, FROM_HERE,
167 base::Bind(&RemoveWatcherOnUIThread, watcher_id,
168 base::Bind(&PostToIOThread<bool>, callback)));
169 }
170
123 } // namespace file_system_operation_runner_util 171 } // namespace file_system_operation_runner_util
124 172
125 } // namespace arc 173 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698