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

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

Issue 2914433002: arc: Use the MIME type returned by the container to handle content URLs (Closed)
Patch Set: Profile check Created 3 years, 6 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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 auto* file_system_instance = ARC_GET_INSTANCE_FOR_METHOD( 97 auto* file_system_instance = ARC_GET_INSTANCE_FOR_METHOD(
98 arc_bridge_service()->file_system(), GetFileSize); 98 arc_bridge_service()->file_system(), GetFileSize);
99 if (!file_system_instance) { 99 if (!file_system_instance) {
100 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 100 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
101 base::BindOnce(callback, -1)); 101 base::BindOnce(callback, -1));
102 return; 102 return;
103 } 103 }
104 file_system_instance->GetFileSize(url.spec(), callback); 104 file_system_instance->GetFileSize(url.spec(), callback);
105 } 105 }
106 106
107 void ArcFileSystemOperationRunner::GetMimeType(
108 const GURL& url,
109 const GetMimeTypeCallback& callback) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 if (should_defer_) {
112 deferred_operations_.emplace_back(
113 base::Bind(&ArcFileSystemOperationRunner::GetMimeType,
114 weak_ptr_factory_.GetWeakPtr(), url, callback));
115 return;
116 }
117 auto* file_system_instance = ARC_GET_INSTANCE_FOR_METHOD(
118 arc_bridge_service()->file_system(), GetMimeType);
119 if (!file_system_instance) {
120 base::ThreadTaskRunnerHandle::Get()->PostTask(
121 FROM_HERE, base::Bind(callback, base::Optional<std::string>()));
dcheng 2017/06/01 11:06:44 Let's use base::nullopt instead of base::Optional<
hashimoto 2017/06/01 11:30:16 Sounds good. Done.
122 return;
123 }
124 file_system_instance->GetMimeType(url.spec(), callback);
125 }
126
107 void ArcFileSystemOperationRunner::OpenFileToRead( 127 void ArcFileSystemOperationRunner::OpenFileToRead(
108 const GURL& url, 128 const GURL& url,
109 const OpenFileToReadCallback& callback) { 129 const OpenFileToReadCallback& callback) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI); 130 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 if (should_defer_) { 131 if (should_defer_) {
112 deferred_operations_.emplace_back( 132 deferred_operations_.emplace_back(
113 base::Bind(&ArcFileSystemOperationRunner::OpenFileToRead, 133 base::Bind(&ArcFileSystemOperationRunner::OpenFileToRead,
114 weak_ptr_factory_.GetWeakPtr(), url, callback)); 134 weak_ptr_factory_.GetWeakPtr(), url, callback));
115 return; 135 return;
116 } 136 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 deferred_operations.swap(deferred_operations_); 324 deferred_operations.swap(deferred_operations_);
305 for (const base::Closure& operation : deferred_operations) { 325 for (const base::Closure& operation : deferred_operations) {
306 operation.Run(); 326 operation.Run();
307 } 327 }
308 328
309 // No deferred operations should be left at this point. 329 // No deferred operations should be left at this point.
310 DCHECK(deferred_operations_.empty()); 330 DCHECK(deferred_operations_.empty());
311 } 331 }
312 332
313 } // namespace arc 333 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698