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

Side by Side Diff: chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.cc

Issue 527773003: Add GetURLForBrowserTab method to the external file system backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handled @kinaba's comments Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/drive/fileapi/file_system_backend_delegate.h" 5 #include "chrome/browser/chromeos/drive/fileapi/file_system_backend_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "chrome/browser/chromeos/drive/file_system_interface.h"
10 #include "chrome/browser/chromeos/drive/file_system_util.h" 11 #include "chrome/browser/chromeos/drive/file_system_util.h"
11 #include "chrome/browser/chromeos/drive/fileapi/async_file_util.h" 12 #include "chrome/browser/chromeos/drive/fileapi/async_file_util.h"
12 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h" 13 #include "chrome/browser/chromeos/drive/fileapi/fileapi_worker.h"
13 #include "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl.h " 14 #include "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_reader_impl.h "
14 #include "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_writer_impl.h " 15 #include "chrome/browser/chromeos/drive/fileapi/webkit_file_stream_writer_impl.h "
15 #include "chrome/browser/drive/drive_api_util.h" 16 #include "chrome/browser/drive/drive_api_util.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "webkit/browser/blob/file_stream_reader.h" 18 #include "webkit/browser/blob/file_stream_reader.h"
18 #include "webkit/browser/fileapi/async_file_util.h" 19 #include "webkit/browser/fileapi/async_file_util.h"
19 #include "webkit/browser/fileapi/file_system_context.h" 20 #include "webkit/browser/fileapi/file_system_context.h"
20 #include "webkit/browser/fileapi/file_system_url.h" 21 #include "webkit/browser/fileapi/file_system_url.h"
21 22
22 using content::BrowserThread; 23 using content::BrowserThread;
23 24
24 namespace drive { 25 namespace drive {
26 namespace {
27
28 void GetURLForBrowserTabOnUIThreadWithResourceEntry(
mtomasz 2014/09/04 05:30:01 nit: Comments are missing. Especially we should co
hirono 2014/09/04 06:10:58 Done.
29 const FileSystemBackendDelegate::URLCallback& callback,
30 FileError error,
31 scoped_ptr<ResourceEntry> entry) {
32 DCHECK_CURRENTLY_ON(BrowserThread::UI);
33 GURL url;
34 if (error == FILE_ERROR_OK && entry->has_file_specific_info() &&
35 entry->file_specific_info().is_hosted_document()) {
36 url = GURL(entry->file_specific_info().alternate_url());
37 }
38 BrowserThread::PostTask(
39 BrowserThread::IO, FROM_HERE, base::Bind(callback, url));
40 }
41
42 void GetURLForBrowserTabOnUIThread(
43 const storage::FileSystemURL& url,
44 const FileSystemBackendDelegate::URLCallback& callback) {
45 DCHECK_CURRENTLY_ON(BrowserThread::UI);
46 FileSystemInterface* const file_system =
47 fileapi_internal::GetFileSystemFromUrl(url);
48 if (!file_system) {
49 BrowserThread::PostTask(
50 BrowserThread::IO, FROM_HERE, base::Bind(callback, GURL()));
51 return;
52 }
53 const base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url);
54 file_system->GetResourceEntry(
55 file_path,
56 base::Bind(&GetURLForBrowserTabOnUIThreadWithResourceEntry, callback));
57
mtomasz 2014/09/04 05:30:01 nit: The empty line should be one line lower?
hirono 2014/09/04 06:10:58 Done.
58 }
59 } // namespace
25 60
26 FileSystemBackendDelegate::FileSystemBackendDelegate() 61 FileSystemBackendDelegate::FileSystemBackendDelegate()
27 : async_file_util_(new internal::AsyncFileUtil) { 62 : async_file_util_(new internal::AsyncFileUtil) {
28 } 63 }
29 64
30 FileSystemBackendDelegate::~FileSystemBackendDelegate() { 65 FileSystemBackendDelegate::~FileSystemBackendDelegate() {
31 } 66 }
32 67
33 storage::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil( 68 storage::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil(
34 storage::FileSystemType type) { 69 storage::FileSystemType type) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 file_path, 114 file_path,
80 offset)); 115 offset));
81 } 116 }
82 117
83 storage::WatcherManager* FileSystemBackendDelegate::GetWatcherManager( 118 storage::WatcherManager* FileSystemBackendDelegate::GetWatcherManager(
84 const storage::FileSystemURL& url) { 119 const storage::FileSystemURL& url) {
85 NOTIMPLEMENTED(); 120 NOTIMPLEMENTED();
86 return NULL; 121 return NULL;
87 } 122 }
88 123
124 void FileSystemBackendDelegate::GetURLForBrowserTab(
125 const storage::FileSystemURL& url,
126 const URLCallback& callback) {
127 DCHECK_CURRENTLY_ON(BrowserThread::IO);
128 BrowserThread::PostTask(
129 BrowserThread::UI,
130 FROM_HERE,
131 base::Bind(&GetURLForBrowserTabOnUIThread, url, callback));
132 }
133
89 } // namespace drive 134 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698