OLD | NEW |
---|---|
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 { | |
kinaba
2014/09/04 04:17:04
put a blank line between namespace { the following
hirono
2014/09/04 04:29:09
Done.
| |
27 void PostURLOnIOThread(const FileSystemBackendDelegate::URLCallback& callback, | |
kinaba
2014/09/04 04:17:04
Maybe: PostURLToIOThread?
Or I think you can remo
hirono
2014/09/04 04:29:09
Removed the function.
| |
28 const GURL& url) { | |
29 BrowserThread::PostTask( | |
30 BrowserThread::IO, FROM_HERE, base::Bind(callback, url)); | |
31 } | |
32 | |
33 void GetURLForBrowserTabOnUIThreadWithResourceEntry( | |
34 const FileSystemBackendDelegate::URLCallback& callback, | |
35 FileError error, | |
36 scoped_ptr<ResourceEntry> entry) { | |
37 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
38 GURL url; | |
39 if (error == FILE_ERROR_OK && entry->has_file_specific_info() && | |
40 entry->file_specific_info().is_hosted_document()) { | |
41 url = GURL(entry->file_specific_info().alternate_url()); | |
42 } | |
43 PostURLOnIOThread(callback, url); | |
44 } | |
45 | |
46 void GetURLForBrowserTabOnUIThread( | |
47 const storage::FileSystemURL& url, | |
48 const FileSystemBackendDelegate::URLCallback& callback) { | |
49 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
50 FileSystemInterface* const file_system = | |
51 fileapi_internal::GetFileSystemFromUrl(url); | |
52 if (!file_system) { | |
53 PostURLOnIOThread(callback, GURL()); | |
54 return; | |
55 } | |
56 const base::FilePath file_path = util::ExtractDrivePathFromFileSystemUrl(url); | |
57 file_system->GetResourceEntry( | |
58 file_path, | |
59 base::Bind(GetURLForBrowserTabOnUIThreadWithResourceEntry, callback)); | |
kinaba
2014/09/04 04:17:04
&GetURLFor...
hirono
2014/09/04 04:29:09
Done.
| |
60 } | |
61 } // namespace | |
25 | 62 |
26 FileSystemBackendDelegate::FileSystemBackendDelegate() | 63 FileSystemBackendDelegate::FileSystemBackendDelegate() |
27 : async_file_util_(new internal::AsyncFileUtil) { | 64 : async_file_util_(new internal::AsyncFileUtil) { |
28 } | 65 } |
29 | 66 |
30 FileSystemBackendDelegate::~FileSystemBackendDelegate() { | 67 FileSystemBackendDelegate::~FileSystemBackendDelegate() { |
31 } | 68 } |
32 | 69 |
33 storage::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil( | 70 storage::AsyncFileUtil* FileSystemBackendDelegate::GetAsyncFileUtil( |
34 storage::FileSystemType type) { | 71 storage::FileSystemType type) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 file_path, | 116 file_path, |
80 offset)); | 117 offset)); |
81 } | 118 } |
82 | 119 |
83 storage::WatcherManager* FileSystemBackendDelegate::GetWatcherManager( | 120 storage::WatcherManager* FileSystemBackendDelegate::GetWatcherManager( |
84 const storage::FileSystemURL& url) { | 121 const storage::FileSystemURL& url) { |
85 NOTIMPLEMENTED(); | 122 NOTIMPLEMENTED(); |
86 return NULL; | 123 return NULL; |
87 } | 124 } |
88 | 125 |
126 void FileSystemBackendDelegate::GetURLForBrowserTab( | |
127 const storage::FileSystemURL& url, | |
128 const URLCallback& callback) { | |
129 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
130 BrowserThread::PostTask( | |
131 BrowserThread::UI, | |
132 FROM_HERE, | |
133 base::Bind(GetURLForBrowserTabOnUIThread, url, callback)); | |
kinaba
2014/09/04 04:17:04
&GetURLFor...
hirono
2014/09/04 04:29:09
Done.
| |
134 } | |
135 | |
89 } // namespace drive | 136 } // namespace drive |
OLD | NEW |