Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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( | |
|
hidehiko
2017/02/17 15:07:19
FYI (off-topic): yusukes@.
On ARC login screen wor
Yusuke Sato
2017/02/17 22:27:09
Acknowledged.
| |
| 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 |
| OLD | NEW |