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

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

Issue 2702723002: Extract kArcEnabled preference from ArcSessionManager part 1. (Closed)
Patch Set: Address comments. 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 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h " 5 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h "
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/optional.h" 10 #include "base/optional.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "chrome/browser/chromeos/arc/arc_util.h"
12 #include "components/arc/arc_bridge_service.h" 13 #include "components/arc/arc_bridge_service.h"
13 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
14 #include "url/gurl.h" 15 #include "url/gurl.h"
15 16
16 using content::BrowserThread; 17 using content::BrowserThread;
17 18
18 namespace arc { 19 namespace arc {
19 20
20 // static 21 // static
21 const char ArcFileSystemOperationRunner::kArcServiceName[] = 22 const char ArcFileSystemOperationRunner::kArcServiceName[] =
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 OnStateChanged(); 155 OnStateChanged();
155 } 156 }
156 157
157 void ArcFileSystemOperationRunner::OnInstanceClosed() { 158 void ArcFileSystemOperationRunner::OnInstanceClosed() {
158 DCHECK_CURRENTLY_ON(BrowserThread::UI); 159 DCHECK_CURRENTLY_ON(BrowserThread::UI);
159 OnStateChanged(); 160 OnStateChanged();
160 } 161 }
161 162
162 void ArcFileSystemOperationRunner::OnStateChanged() { 163 void ArcFileSystemOperationRunner::OnStateChanged() {
163 DCHECK_CURRENTLY_ON(BrowserThread::UI); 164 DCHECK_CURRENTLY_ON(BrowserThread::UI);
164 SetShouldDefer(ArcSessionManager::Get()->IsArcPlayStoreEnabled() && 165 // TODO(hidehiko): Revisit the condition, when ARC is running without
165 !arc_bridge_service()->file_system()->has_instance()); 166 // profile.
167 SetShouldDefer(
168 IsArcPlayStoreEnabledForProfile(ArcSessionManager::Get()->profile()) &&
169 !arc_bridge_service()->file_system()->has_instance());
166 } 170 }
167 171
168 void ArcFileSystemOperationRunner::SetShouldDefer(bool should_defer) { 172 void ArcFileSystemOperationRunner::SetShouldDefer(bool should_defer) {
169 DCHECK_CURRENTLY_ON(BrowserThread::UI); 173 DCHECK_CURRENTLY_ON(BrowserThread::UI);
170 174
171 should_defer_ = should_defer; 175 should_defer_ = should_defer;
172 176
173 if (should_defer_) 177 if (should_defer_)
174 return; 178 return;
175 179
176 // Run deferred operations. 180 // Run deferred operations.
177 std::vector<base::Closure> deferred_operations; 181 std::vector<base::Closure> deferred_operations;
178 deferred_operations.swap(deferred_operations_); 182 deferred_operations.swap(deferred_operations_);
179 for (const base::Closure& operation : deferred_operations) { 183 for (const base::Closure& operation : deferred_operations) {
180 operation.Run(); 184 operation.Run();
181 } 185 }
182 186
183 // No deferred operations should be left at this point. 187 // No deferred operations should be left at this point.
184 DCHECK(deferred_operations_.empty()); 188 DCHECK(deferred_operations_.empty());
185 } 189 }
186 190
187 } // namespace arc 191 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_util_unittest.cc ('k') | chrome/browser/chromeos/extensions/wallpaper_manager_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698