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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/create_file_operation.h

Issue 137423010: drive: Support offline file creation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_DRIVE_FILE_SYSTEM_CREATE_FILE_OPERATION_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_FILE_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_FILE_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_FILE_OPERATION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h" 11 #include "chrome/browser/chromeos/drive/file_errors.h"
13 #include "google_apis/drive/gdata_errorcode.h"
14 12
15 namespace base { 13 namespace base {
16 class FilePath; 14 class FilePath;
17 class SequencedTaskRunner; 15 class SequencedTaskRunner;
18 } // namespace base 16 } // namespace base
19 17
20 namespace google_apis {
21 class ResourceEntry;
22 } // namespace google_apis
23
24 namespace drive { 18 namespace drive {
25 19
26 namespace internal { 20 namespace internal {
27 class FileCache;
28 class ResourceMetadata; 21 class ResourceMetadata;
29 } // namespace internal 22 } // namespace internal
30 23
31 struct EntryInfoPairResult;
32 class JobScheduler;
33 class ResourceEntry; 24 class ResourceEntry;
34 25
35 namespace file_system { 26 namespace file_system {
36 27
37 class OperationObserver; 28 class OperationObserver;
38 29
39 // This class encapsulates the drive CreateFile function. It is responsible for 30 // This class encapsulates the drive CreateFile function. It is responsible for
40 // sending the request to the drive API, then updating the local state and 31 // sending the request to the drive API, then updating the local state and
41 // metadata to reflect the new state. 32 // metadata to reflect the new state.
42 class CreateFileOperation { 33 class CreateFileOperation {
43 public: 34 public:
44 CreateFileOperation(base::SequencedTaskRunner* blocking_task_runner, 35 CreateFileOperation(base::SequencedTaskRunner* blocking_task_runner,
45 OperationObserver* observer, 36 OperationObserver* observer,
46 JobScheduler* scheduler, 37 internal::ResourceMetadata* metadata);
47 internal::ResourceMetadata* metadata,
48 internal::FileCache* cache);
49 ~CreateFileOperation(); 38 ~CreateFileOperation();
50 39
51 // Creates an empty file at |file_path| in the remote server. When the file 40 // Creates an empty file at |file_path|. When the file
52 // already exists at that path, the operation fails if |is_exclusive| is true, 41 // already exists at that path, the operation fails if |is_exclusive| is true,
53 // and it succeeds without doing anything if the flag is false. 42 // and it succeeds without doing anything if the flag is false.
54 // If |mime_type| is non-empty, it is used as the mime type of the entry. If 43 // If |mime_type| is non-empty, it is used as the mime type of the entry. If
55 // the parameter is empty, the type is guessed from |file_path|. 44 // the parameter is empty, the type is guessed from |file_path|.
56 // 45 //
57 // |callback| must not be null. 46 // |callback| must not be null.
58 void CreateFile(const base::FilePath& file_path, 47 void CreateFile(const base::FilePath& file_path,
59 bool is_exclusive, 48 bool is_exclusive,
60 const std::string& mime_type, 49 const std::string& mime_type,
61 const FileOperationCallback& callback); 50 const FileOperationCallback& callback);
62 51
63 private: 52 private:
64 // Part of CreateFile(). Called after the precondition check is completed.
65 void CreateFileAfterCheckPreCondition(const base::FilePath& file_path,
66 const FileOperationCallback& callback,
67 std::string* parent_resource_id,
68 std::string* mime_type,
69 FileError error);
70
71 // Part of CreateFile(). Called after the server side file creation is
72 // completed.
73 void CreateFileAfterUpload(
74 const FileOperationCallback& callback,
75 google_apis::GDataErrorCode error,
76 scoped_ptr<google_apis::ResourceEntry> resource_entry);
77
78 // Part of CreateFile(). Called after the updating local state is completed. 53 // Part of CreateFile(). Called after the updating local state is completed.
79 void CreateFileAfterUpdateLocalState(const FileOperationCallback& callback, 54 void CreateFileAfterUpdateLocalState(const FileOperationCallback& callback,
80 base::FilePath* file_path, 55 const base::FilePath& file_path,
56 bool is_exclusive,
57 ResourceEntry* entry,
81 FileError error); 58 FileError error);
82 59
83 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 60 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
84 OperationObserver* observer_; 61 OperationObserver* observer_;
85 JobScheduler* scheduler_;
86 internal::ResourceMetadata* metadata_; 62 internal::ResourceMetadata* metadata_;
87 internal::FileCache* cache_;
88 63
89 // Note: This should remain the last member so it'll be destroyed and 64 // Note: This should remain the last member so it'll be destroyed and
90 // invalidate the weak pointers before any other members are destroyed. 65 // invalidate the weak pointers before any other members are destroyed.
91 base::WeakPtrFactory<CreateFileOperation> weak_ptr_factory_; 66 base::WeakPtrFactory<CreateFileOperation> weak_ptr_factory_;
92 DISALLOW_COPY_AND_ASSIGN(CreateFileOperation); 67 DISALLOW_COPY_AND_ASSIGN(CreateFileOperation);
93 }; 68 };
94 69
95 } // namespace file_system 70 } // namespace file_system
96 } // namespace drive 71 } // namespace drive
97 72
98 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_FILE_OPERATION_H_ 73 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_FILE_SYSTEM_CREATE_FILE_OPERATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698