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

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

Issue 2511973003: Use ArcFileSystemInstance to access files on ARC. (Closed)
Patch Set: Rebased to ToT. Created 4 years 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
« no previous file with comments | « chrome/browser/chromeos/arc/fileapi/intent_helper_util.h ('k') | components/arc/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/arc/fileapi/intent_helper_util.h"
6
7 #include "components/arc/arc_bridge_service.h"
8 #include "content/public/browser/browser_thread.h"
9
10 namespace arc {
11
12 namespace intent_helper_util {
13
14 namespace {
15
16 constexpr uint32_t kGetFileSizeVersion = 15;
17 constexpr uint32_t kOpenFileToReadVersion = 15;
18
19 void OnGetFileSize(const GetFileSizeCallback& callback, int64_t size) {
20 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
21 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
22 base::Bind(callback, size));
23 }
24
25 void GetFileSizeOnUIThread(const GURL& arc_url,
26 const GetFileSizeCallback& callback) {
27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
28 auto* arc_bridge_service = arc::ArcBridgeService::Get();
29 if (!arc_bridge_service) {
30 LOG(ERROR) << "Failed to get ArcBridgeService.";
31 OnGetFileSize(callback, -1);
32 return;
33 }
34 mojom::IntentHelperInstance* intent_helper_instance =
35 arc_bridge_service->intent_helper()->GetInstanceForMethod(
36 "GetFileSizeDeprecated", kGetFileSizeVersion);
37 if (!intent_helper_instance) {
38 LOG(ERROR) << "Failed to get IntentHelperInstance.";
39 OnGetFileSize(callback, -1);
40 return;
41 }
42 intent_helper_instance->GetFileSizeDeprecated(
43 arc_url.spec(), base::Bind(&OnGetFileSize, callback));
44 }
45
46 void OnOpenFileToRead(const OpenFileToReadCallback& callback,
47 mojo::ScopedHandle handle) {
48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
49 content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
50 base::Bind(callback, base::Passed(&handle)));
51 }
52
53 void OpenFileToReadOnUIThread(const GURL& arc_url,
54 const OpenFileToReadCallback& callback) {
55 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
56 auto* arc_bridge_service = arc::ArcBridgeService::Get();
57 if (!arc_bridge_service) {
58 LOG(ERROR) << "Failed to get ArcBridgeService.";
59 OnOpenFileToRead(callback, mojo::ScopedHandle());
60 return;
61 }
62 mojom::IntentHelperInstance* intent_helper_instance =
63 arc_bridge_service->intent_helper()->GetInstanceForMethod(
64 "OpenFileToReadDeprecated", kOpenFileToReadVersion);
65 if (!intent_helper_instance) {
66 LOG(ERROR) << "Failed to get IntentHelperInstance.";
67 OnOpenFileToRead(callback, mojo::ScopedHandle());
68 return;
69 }
70 intent_helper_instance->OpenFileToReadDeprecated(
71 arc_url.spec(), base::Bind(&OnOpenFileToRead, callback));
72 }
73
74 } // namespace
75
76 void GetFileSizeOnIOThread(const GURL& arc_url,
77 const GetFileSizeCallback& callback) {
78 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
79 content::BrowserThread::PostTask(
80 content::BrowserThread::UI, FROM_HERE,
81 base::Bind(&GetFileSizeOnUIThread, arc_url, callback));
82 }
83
84 void OpenFileToReadOnIOThread(const GURL& arc_url,
85 const OpenFileToReadCallback& callback) {
86 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
87 content::BrowserThread::PostTask(
88 content::BrowserThread::UI, FROM_HERE,
89 base::Bind(&OpenFileToReadOnUIThread, arc_url, callback));
90 }
91
92 } // namespace intent_helper_util
93
94 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/fileapi/intent_helper_util.h ('k') | components/arc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698