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

Side by Side Diff: chrome/browser/chromeos/gdata/gdata_file_system.h

Issue 9583031: gdata:: Add GDataFileSystem::GetFile(). (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 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 6 #define CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 19 matching lines...) Expand all
30 class GDataFileBase { 30 class GDataFileBase {
31 public: 31 public:
32 explicit GDataFileBase(GDataDirectory* parent); 32 explicit GDataFileBase(GDataDirectory* parent);
33 virtual ~GDataFileBase(); 33 virtual ~GDataFileBase();
34 // Converts DocumentEntry into GDataFileBase. 34 // Converts DocumentEntry into GDataFileBase.
35 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent, 35 static GDataFileBase* FromDocumentEntry(GDataDirectory* parent,
36 DocumentEntry* doc); 36 DocumentEntry* doc);
37 virtual GDataFile* AsGDataFile(); 37 virtual GDataFile* AsGDataFile();
38 virtual GDataDirectory* AsGDataDirectory(); 38 virtual GDataDirectory* AsGDataDirectory();
39 GDataDirectory* parent() { return parent_; } 39 GDataDirectory* parent() { return parent_; }
40 const GURL& content_url() const { return content_url_; }
41 const base::PlatformFileInfo& file_info() const { return file_info_; } 40 const base::PlatformFileInfo& file_info() const { return file_info_; }
42 const FilePath::StringType& file_name() const { return file_name_; } 41 const FilePath::StringType& file_name() const { return file_name_; }
43 const FilePath::StringType& original_file_name() const { 42 const FilePath::StringType& original_file_name() const {
44 return original_file_name_; 43 return original_file_name_;
45 } 44 }
46 void set_file_name(const FilePath::StringType& name) { file_name_ = name; } 45 void set_file_name(const FilePath::StringType& name) { file_name_ = name; }
46
47 // The content URL is used for downloading regular files as is.
48 // TODO(zelidrag): Will give better description when reviewing code.
zel 2012/03/02 23:44:04 i am ok with this descirption
satorux1 2012/03/03 00:39:10 Done.
49 const GURL& content_url() const { return content_url_; }
50
51 // The self URL is used for removing files and hosted documents.
52 // TODO(zelidrag): Will give better description when reviewing code.
zel 2012/03/02 23:44:04 same here
satorux1 2012/03/03 00:39:10 Done.
47 const GURL& self_url() const { return self_url_; } 53 const GURL& self_url() const { return self_url_; }
54
48 // Returns virtual file path representing this file system entry. This path 55 // Returns virtual file path representing this file system entry. This path
49 // corresponds to file path expected by public methods of GDataFileSyste 56 // corresponds to file path expected by public methods of GDataFileSyste
50 // class. 57 // class.
51 FilePath GetFilePath(); 58 FilePath GetFilePath();
52 59
53 protected: 60 protected:
54 base::PlatformFileInfo file_info_; 61 base::PlatformFileInfo file_info_;
55 FilePath::StringType file_name_; 62 FilePath::StringType file_name_;
56 FilePath::StringType original_file_name_; 63 FilePath::StringType original_file_name_;
57 // Files with the same original name will be uniquely identified with this 64 // Files with the same original name will be uniquely identified with this
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 ~FindFileParams(); 237 ~FindFileParams();
231 238
232 const FilePath file_path; 239 const FilePath file_path;
233 const bool require_content; 240 const bool require_content;
234 const FilePath directory_path; 241 const FilePath directory_path;
235 const GURL feed_url; 242 const GURL feed_url;
236 const bool initial_feed; 243 const bool initial_feed;
237 const scoped_refptr<FindFileDelegate> delegate; 244 const scoped_refptr<FindFileDelegate> delegate;
238 }; 245 };
239 246
247 // Used for file operations like removing files.
240 typedef base::Callback<void(base::PlatformFileError error)> 248 typedef base::Callback<void(base::PlatformFileError error)>
241 FileOperationCallback; 249 FileOperationCallback;
242 250
251 // Used to get files from the file system.
252 typedef base::Callback<void(base::PlatformFileError error,
253 const FilePath& file_path)>
254 GetFileCallback;
255
243 // ProfileKeyedService override: 256 // ProfileKeyedService override:
244 virtual void Shutdown() OVERRIDE; 257 virtual void Shutdown() OVERRIDE;
245 258
246 // Authenticates the user by fetching the auth token as 259 // Authenticates the user by fetching the auth token as
247 // needed. |callback| will be run with the error code and the auth 260 // needed. |callback| will be run with the error code and the auth
248 // token, on the thread this function is run. 261 // token, on the thread this function is run.
249 // 262 //
250 // Must be called on UI thread. 263 // Must be called on UI thread.
251 void Authenticate(const AuthStatusCallback& callback); 264 void Authenticate(const AuthStatusCallback& callback);
252 265
(...skipping 24 matching lines...) Expand all
277 // an error is raised in case a directory is already present at the 290 // an error is raised in case a directory is already present at the
278 // |directory_path|. If |is_recursive| is true, the call creates parent 291 // |directory_path|. If |is_recursive| is true, the call creates parent
279 // directories as needed just like mkdir -p does. 292 // directories as needed just like mkdir -p does.
280 // 293 //
281 // Can be called from any thread. |callback| is run on the calling thread. 294 // Can be called from any thread. |callback| is run on the calling thread.
282 void CreateDirectory(const FilePath& directory_path, 295 void CreateDirectory(const FilePath& directory_path,
283 bool is_exclusive, 296 bool is_exclusive,
284 bool is_recursive, 297 bool is_recursive,
285 const FileOperationCallback& callback); 298 const FileOperationCallback& callback);
286 299
287 // Initiates directory feed fetching operation and continues previously 300 // Gets |file_path| from the file system. The file entry represented by
301 // |file_path| needs to be present in in-memory representation of the file
302 // system in order to be retrieved. If the file is not cached, the file
303 // will be downloaded through gdata api.
304 //
305 // Can be called from any thread. |callback| is run on the calling thread.
306 void GetFile(const FilePath& file_path, const GetFileCallback& callback);
307
288 // initiated FindFileByPath() attempt upon its completion. Safe to be called 308 // initiated FindFileByPath() attempt upon its completion. Safe to be called
289 // from any thread. Internally, it will route content refresh request to 309 // from any thread. Internally, it will route content refresh request to
290 // DocumentsService::GetDocuments() which will initiated content 310 // DocumentsService::GetDocuments() which will initiated content
291 // fetching from UI thread as required by gdata library (UrlFetcher). 311 // fetching from UI thread as required by gdata library (UrlFetcher).
292 // 312 //
293 // Can be called from any thread. 313 // Can be called from any thread.
294 void StartDirectoryRefresh(const FindFileParams& params); 314 void StartDirectoryRefresh(const FindFileParams& params);
295 315
316 // Finds file object by |file_path| and returns the file info.
317 // Returns NULL if it does not find the file.
318 GDataFileBase* GetGDataFileInfoFromPath(const FilePath& file_path);
319
296 private: 320 private:
297 friend class GDataFileSystemFactory; 321 friend class GDataFileSystemFactory;
298 friend class GDataFileSystemTest; 322 friend class GDataFileSystemTest;
299 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest, 323 FRIEND_TEST_ALL_PREFIXES(GDataFileSystemTest,
300 FindFirstMissingParentDirectory); 324 FindFirstMissingParentDirectory);
301 325
302 // Defines possible search results of FindFirstMissingParentDirectory(). 326 // Defines possible search results of FindFirstMissingParentDirectory().
303 enum FindMissingDirectoryResult { 327 enum FindMissingDirectoryResult {
304 // Target directory found, it's not a directory. 328 // Target directory found, it's not a directory.
305 FOUND_INVALID, 329 FOUND_INVALID,
(...skipping 22 matching lines...) Expand all
328 scoped_refptr<base::MessageLoopProxy> proxy; 352 scoped_refptr<base::MessageLoopProxy> proxy;
329 }; 353 };
330 354
331 explicit GDataFileSystem(Profile* profile); 355 explicit GDataFileSystem(Profile* profile);
332 virtual ~GDataFileSystem(); 356 virtual ~GDataFileSystem();
333 357
334 // Unsafe (unlocked) version of the function above. 358 // Unsafe (unlocked) version of the function above.
335 void UnsafeFindFileByPath(const FilePath& file_path, 359 void UnsafeFindFileByPath(const FilePath& file_path,
336 scoped_refptr<FindFileDelegate> delegate); 360 scoped_refptr<FindFileDelegate> delegate);
337 361
338 // Finds file object by |file_path| and returns its gdata self-url.
339 // Returns empty GURL if it does not find the file.
340 GURL GetDocumentUrlFromPath(const FilePath& file_path);
341
342 // Converts document feed from gdata service into DirectoryInfo. On failure, 362 // Converts document feed from gdata service into DirectoryInfo. On failure,
343 // returns NULL and fills in |error| with an appropriate value. 363 // returns NULL and fills in |error| with an appropriate value.
344 GDataDirectory* ParseGDataFeed(GDataErrorCode status, 364 GDataDirectory* ParseGDataFeed(GDataErrorCode status,
345 base::Value* data, 365 base::Value* data,
346 base::PlatformFileError *error); 366 base::PlatformFileError *error);
347 367
348 // Callback for handling feed content fetching while searching for file info. 368 // Callback for handling feed content fetching while searching for file info.
349 // This callback is invoked after async feed fetch operation that was 369 // This callback is invoked after async feed fetch operation that was
350 // invoked by StartDirectoryRefresh() completes. This callback will update 370 // invoked by StartDirectoryRefresh() completes. This callback will update
351 // the content of the refreshed directory object and continue initially 371 // the content of the refreshed directory object and continue initially
(...skipping 10 matching lines...) Expand all
362 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, 382 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
363 GDataErrorCode status, 383 GDataErrorCode status,
364 const GURL& document_url); 384 const GURL& document_url);
365 385
366 // Callback for handling directory create requests. 386 // Callback for handling directory create requests.
367 void OnCreateDirectoryCompleted( 387 void OnCreateDirectoryCompleted(
368 const CreateDirectoryParams& params, 388 const CreateDirectoryParams& params,
369 GDataErrorCode status, 389 GDataErrorCode status,
370 base::Value* created_entry); 390 base::Value* created_entry);
371 391
392 // Callback for handling file downloading requests.
393 void OnFileDownloaded(
394 const GetFileCallback& callback,
395 scoped_refptr<base::MessageLoopProxy> message_loop_proxy,
396 GDataErrorCode status,
397 const GURL& content_url,
398 const FilePath& temp_file);
399
372 // Removes file under |file_path| from in-memory snapshot of the file system. 400 // Removes file under |file_path| from in-memory snapshot of the file system.
373 // Return PLATFORM_FILE_OK if successful. 401 // Return PLATFORM_FILE_OK if successful.
374 base::PlatformFileError RemoveFileFromFileSystem(const FilePath& file_path); 402 base::PlatformFileError RemoveFileFromFileSystem(const FilePath& file_path);
375 403
376 // Updates content of the directory identified with |directory_path|. If the 404 // Updates content of the directory identified with |directory_path|. If the
377 // feed was not complete, it will return URL for the remaining portion in 405 // feed was not complete, it will return URL for the remaining portion in
378 // |next_feed|. On success, returns PLATFORM_FILE_OK. 406 // |next_feed|. On success, returns PLATFORM_FILE_OK.
379 base::PlatformFileError UpdateDirectoryWithDocumentFeed( 407 base::PlatformFileError UpdateDirectoryWithDocumentFeed(
380 const FilePath& directory_path, 408 const FilePath& directory_path,
381 const GURL& feed_url, 409 const GURL& feed_url,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 virtual ~GDataFileSystemFactory(); 464 virtual ~GDataFileSystemFactory();
437 465
438 // ProfileKeyedServiceFactory: 466 // ProfileKeyedServiceFactory:
439 virtual ProfileKeyedService* BuildServiceInstanceFor( 467 virtual ProfileKeyedService* BuildServiceInstanceFor(
440 Profile* profile) const OVERRIDE; 468 Profile* profile) const OVERRIDE;
441 }; 469 };
442 470
443 } // namespace gdata 471 } // namespace gdata
444 472
445 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_ 473 #endif // CHROME_BROWSER_CHROMEOS_GDATA_GDATA_FILE_SYSTEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698