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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system_proxy.cc

Issue 9580016: Fixed remaining CL comments from review of http://codereview.chromium.org/9561009/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/gdata/gdata_file_system_proxy.h" 5 #include "chrome/browser/chromeos/gdata/gdata_file_system_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // thread to ensure its specializations will provide reply on it. 43 // thread to ensure its specializations will provide reply on it.
44 class FindFileDelegateReplyBase : public FindFileDelegate { 44 class FindFileDelegateReplyBase : public FindFileDelegate {
45 public: 45 public:
46 FindFileDelegateReplyBase( 46 FindFileDelegateReplyBase(
47 GDataFileSystem* file_system, 47 GDataFileSystem* file_system,
48 const FilePath& search_file_path, 48 const FilePath& search_file_path,
49 bool require_content) 49 bool require_content)
50 : file_system_(file_system), 50 : file_system_(file_system),
51 search_file_path_(search_file_path), 51 search_file_path_(search_file_path),
52 require_content_(require_content) { 52 require_content_(require_content) {
53 BrowserThread::ID thread_id; 53 reply_message_proxy_ = MessageLoopProxy::current();
54 CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_id));
55 replay_message_proxy_ =
56 BrowserThread::GetMessageLoopProxyForThread(thread_id);
57 } 54 }
58 55
59 virtual ~FindFileDelegateReplyBase() {} 56 virtual ~FindFileDelegateReplyBase() {}
60 57
61 // chromeos::FindFileDelegate overrides. 58 // chromeos::FindFileDelegate overrides.
62 virtual FindFileTraversalCommand OnEnterDirectory( 59 virtual FindFileTraversalCommand OnEnterDirectory(
63 const FilePath& current_directory_path, 60 const FilePath& current_directory_path,
64 GDataDirectory* current_dir) { 61 GDataDirectory* current_dir) {
65 return CheckAndRefreshContent(current_directory_path, current_dir) ? 62 return CheckAndRefreshContent(current_directory_path, current_dir) ?
66 FIND_FILE_CONTINUES : FIND_FILE_TERMINATES; 63 FIND_FILE_CONTINUES : FIND_FILE_TERMINATES;
(...skipping 24 matching lines...) Expand all
91 } 88 }
92 return true; 89 return true;
93 } 90 }
94 91
95 protected: 92 protected:
96 GDataFileSystem* file_system_; 93 GDataFileSystem* file_system_;
97 // Search file path. 94 // Search file path.
98 FilePath search_file_path_; 95 FilePath search_file_path_;
99 // True if the final directory content is required. 96 // True if the final directory content is required.
100 bool require_content_; 97 bool require_content_;
101 scoped_refptr<MessageLoopProxy> replay_message_proxy_; 98 scoped_refptr<MessageLoopProxy> reply_message_proxy_;
102 }; 99 };
103 100
104 // GetFileInfoDelegate is used to handle results of proxy's content search 101 // GetFileInfoDelegate is used to handle results of proxy's content search
105 // during GetFileInfo call and route reply to the calling message loop. 102 // during GetFileInfo call and route reply to the calling message loop.
106 class GetFileInfoDelegate : public FindFileDelegateReplyBase { 103 class GetFileInfoDelegate : public FindFileDelegateReplyBase {
107 public: 104 public:
108 GetFileInfoDelegate( 105 GetFileInfoDelegate(
109 GDataFileSystem* file_system, 106 GDataFileSystem* file_system,
110 const FilePath& search_file_path, 107 const FilePath& search_file_path,
111 const FileSystemOperationInterface::GetMetadataCallback& callback) 108 const FileSystemOperationInterface::GetMetadataCallback& callback)
(...skipping 19 matching lines...) Expand all
131 Reply(error, base::PlatformFileInfo(), FilePath()); 128 Reply(error, base::PlatformFileInfo(), FilePath());
132 } 129 }
133 130
134 private: 131 private:
135 132
136 // Relays reply back to the callback on calling thread. 133 // Relays reply back to the callback on calling thread.
137 void Reply(base::PlatformFileError result, 134 void Reply(base::PlatformFileError result,
138 const base::PlatformFileInfo& file_info, 135 const base::PlatformFileInfo& file_info,
139 const FilePath& platform_path) { 136 const FilePath& platform_path) {
140 if (!callback_.is_null()) { 137 if (!callback_.is_null()) {
141 replay_message_proxy_->PostTask(FROM_HERE, 138 reply_message_proxy_->PostTask(FROM_HERE,
142 Bind(&GetFileInfoDelegate::ReplyOnCallingThread, 139 Bind(&GetFileInfoDelegate::ReplyOnCallingThread,
143 this, 140 this,
144 result, 141 result,
145 file_info, 142 file_info,
146 platform_path)); 143 platform_path));
147 } 144 }
148 } 145 }
149 146
150 // Responds to callback. 147 // Responds to callback.
151 void ReplyOnCallingThread( 148 void ReplyOnCallingThread(
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 Reply(error, std::vector<base::FileUtilProxy::Entry>(), false); 208 Reply(error, std::vector<base::FileUtilProxy::Entry>(), false);
212 } 209 }
213 210
214 private: 211 private:
215 212
216 // Relays reply back to the callback on calling thread. 213 // Relays reply back to the callback on calling thread.
217 void Reply(base::PlatformFileError result, 214 void Reply(base::PlatformFileError result,
218 const std::vector<base::FileUtilProxy::Entry>& file_list, 215 const std::vector<base::FileUtilProxy::Entry>& file_list,
219 bool has_more) { 216 bool has_more) {
220 if (!callback_.is_null()) { 217 if (!callback_.is_null()) {
221 replay_message_proxy_->PostTask(FROM_HERE, 218 reply_message_proxy_->PostTask(FROM_HERE,
222 Bind(&ReadDirectoryDelegate::ReplyOnCallingThread, 219 Bind(&ReadDirectoryDelegate::ReplyOnCallingThread,
223 this, 220 this,
224 result, 221 result,
225 file_list, 222 file_list,
226 has_more)); 223 has_more));
227 } 224 }
228 } 225 }
229 226
230 // Responds to callback. 227 // Responds to callback.
231 void ReplyOnCallingThread( 228 void ReplyOnCallingThread(
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 // what platform you're on. 312 // what platform you're on.
316 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown; 313 fileapi::FileSystemType type = fileapi::kFileSystemTypeUnknown;
317 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) || 314 if (!fileapi::CrackFileSystemURL(url, NULL, &type, file_path) ||
318 type != fileapi::kFileSystemTypeExternal) { 315 type != fileapi::kFileSystemTypeExternal) {
319 return false; 316 return false;
320 } 317 }
321 return true; 318 return true;
322 } 319 }
323 320
324 } // namespace gdata 321 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698