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

Side by Side Diff: chrome/browser/chromeos/drive/drive_resource_metadata.h

Issue 11293247: Make DriveFeedProcessor asynchronous. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: indentation Created 8 years, 1 month 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_DRIVE_DRIVE_RESOURCE_METADATA_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
13 #include "base/file_path.h" 14 #include "base/file_path.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
16 #include "base/time.h" 17 #include "base/time.h"
17 #include "chrome/browser/chromeos/drive/drive_file_error.h" 18 #include "chrome/browser/chromeos/drive/drive_file_error.h"
18 19
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // If |error| is not DRIVE_FILE_OK, |entry_proto| is set to NULL. 83 // If |error| is not DRIVE_FILE_OK, |entry_proto| is set to NULL.
83 // 84 //
84 // |drive_file_path| parameter is provided as DriveEntryProto does not contain 85 // |drive_file_path| parameter is provided as DriveEntryProto does not contain
85 // the Drive file path (i.e. only contains the base name without parent 86 // the Drive file path (i.e. only contains the base name without parent
86 // directory names). 87 // directory names).
87 typedef base::Callback<void(DriveFileError error, 88 typedef base::Callback<void(DriveFileError error,
88 const FilePath& drive_file_path, 89 const FilePath& drive_file_path,
89 scoped_ptr<DriveEntryProto> entry_proto)> 90 scoped_ptr<DriveEntryProto> entry_proto)>
90 GetEntryInfoWithFilePathCallback; 91 GetEntryInfoWithFilePathCallback;
91 92
93 // Used to get a set of changed directories for feed processing.
94 typedef base::Callback<void(const std::set<FilePath>&)>
95 ChangedDirectoriesCallback;
96
92 // This is a part of EntryInfoPairResult. 97 // This is a part of EntryInfoPairResult.
93 struct EntryInfoResult { 98 struct EntryInfoResult {
94 EntryInfoResult(); 99 EntryInfoResult();
95 ~EntryInfoResult(); 100 ~EntryInfoResult();
96 101
97 FilePath path; 102 FilePath path;
98 DriveFileError error; 103 DriveFileError error;
99 scoped_ptr<DriveEntryProto> proto; 104 scoped_ptr<DriveEntryProto> proto;
100 }; 105 };
101 106
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // |first_path| is not found, this function does not try to get the 222 // |first_path| is not found, this function does not try to get the
218 // entry of |second_path|. 223 // entry of |second_path|.
219 // 224 //
220 // Must be called from UI thread. |callback| is run on UI thread. 225 // Must be called from UI thread. |callback| is run on UI thread.
221 // |callback| must not be null. 226 // |callback| must not be null.
222 void GetEntryInfoPairByPaths( 227 void GetEntryInfoPairByPaths(
223 const FilePath& first_path, 228 const FilePath& first_path,
224 const FilePath& second_path, 229 const FilePath& second_path,
225 const GetEntryInfoPairCallback& callback); 230 const GetEntryInfoPairCallback& callback);
226 231
227 // Replaces a file entry with the same resource id as |doc_entry| by deleting 232 // Refreshes a drive entry with the same resource id as |entry_proto|.
228 // the existing entry, creating a new DriveFile from |doc_entry|, and adding 233 // |callback| is run with the error, file path and proto of the entry.
229 // it to the parent of the old entry. For directories, this just returns the 234 // |callback| must not be null.
230 // existing directory proto. |callback| is run with the error, file path and 235 void RefreshEntryProto(const DriveEntryProto& entry_proto,
231 // proto of the entry. |callback| must not be null. 236 const GetEntryInfoWithFilePathCallback& callback);
237
238 // Refresh a drive entry with resource_id that matches that of |doc_entry|,
239 // with |doc_entry|.
240 // |callback| must not be null.
241 // TODO(achuith): Deprecate this in favor of RefreshEntryProto above.
232 void RefreshFile(scoped_ptr<google_apis::DocumentEntry> doc_entry, 242 void RefreshFile(scoped_ptr<google_apis::DocumentEntry> doc_entry,
233 const GetEntryInfoWithFilePathCallback& callback); 243 const GetEntryInfoWithFilePathCallback& callback);
234 244
235 // Removes all child files of |directory| and replaces them with 245 // Removes all child files of |directory| and replaces them with
236 // |entry_proto_map|. |callback| is called with the directory path. 246 // |entry_proto_map|. |callback| is called with the directory path.
237 // |callback| must not be null. 247 // |callback| must not be null.
238 void RefreshDirectory(const std::string& directory_resource_id, 248 void RefreshDirectory(const std::string& directory_resource_id,
239 const DriveEntryProtoMap& entry_proto_map, 249 const DriveEntryProtoMap& entry_proto_map,
240 const FileMoveCallback& callback); 250 const FileMoveCallback& callback);
241 251
252 // Add |entry_proto| to the metadata tree.
253 // |callback| must not be null.
254 void AddEntryToParent(const DriveEntryProto& entry_proto,
255 const FileMoveCallback& callback);
256
257 // Get changed directories related to entry pointed to by |resource_id|. This
258 // includes the immediate parent, self, and children.
259 void GetChangedDirectories(
260 const std::string& resource_id,
261 const ChangedDirectoriesCallback& changed_dirs_callback);
262
263 // Helper function to get a parent directory given |parent_resource_id|.
264 // Returns root if |parent_resource_id| is not set.
satorux1 2012/11/13 22:56:45 is not set -> is empty? This also seems to return
achuithb 2012/11/14 01:01:36 Done.
265 DriveDirectory* GetParent(const std::string& parent_resource_id);
266
242 // Moves all child entries from the directory represented by 267 // Moves all child entries from the directory represented by
243 // |source_resource_id| to the directory respresented by 268 // |source_resource_id| to the directory respresented by
244 // |destination_resource_id|. |callback| must not be null. 269 // |destination_resource_id|. |callback| must not be null.
270 // TODO(achuith): Delete this.
245 void TakeOverEntries(const std::string& source_resource_id, 271 void TakeOverEntries(const std::string& source_resource_id,
246 const std::string& destination_resource_id, 272 const std::string& destination_resource_id,
247 const FileMoveCallback& callback); 273 const FileMoveCallback& callback);
248 274
249 // Serializes/Parses to/from string via proto classes. 275 // Serializes/Parses to/from string via proto classes.
250 void SerializeToString(std::string* serialized_proto) const; 276 void SerializeToString(std::string* serialized_proto) const;
251 bool ParseFromString(const std::string& serialized_proto); 277 bool ParseFromString(const std::string& serialized_proto);
252 278
253 // Restores from and saves to database, calling |callback| asynchronously. 279 // Restores from and saves to database, calling |callback| asynchronously.
254 // |callback| must not be null. 280 // |callback| must not be null.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been 314 // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been
289 // asynchronously fetched. 315 // asynchronously fetched.
290 void GetEntryInfoPairByPathsAfterGetSecond( 316 void GetEntryInfoPairByPathsAfterGetSecond(
291 const FilePath& second_path, 317 const FilePath& second_path,
292 const GetEntryInfoPairCallback& callback, 318 const GetEntryInfoPairCallback& callback,
293 scoped_ptr<EntryInfoPairResult> result, 319 scoped_ptr<EntryInfoPairResult> result,
294 DriveFileError error, 320 DriveFileError error,
295 scoped_ptr<DriveEntryProto> entry_proto); 321 scoped_ptr<DriveEntryProto> entry_proto);
296 322
297 // Searches for |file_path| synchronously. 323 // Searches for |file_path| synchronously.
298 // TODO(satorux): Replace this with an async version crbug.com/137160
299 DriveEntry* FindEntryByPathSync(const FilePath& file_path); 324 DriveEntry* FindEntryByPathSync(const FilePath& file_path);
300 325
326 // Helper function to add |entry_proto| as a child to |directory|.
327 // |callback| must not be null.
328 void AddEntryToDirectoryInternal(DriveDirectory* directory,
329 const DriveEntryProto& entry_proto,
330 const FileMoveCallback& callback);
331
301 // Private data members. 332 // Private data members.
302 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 333 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
303 scoped_ptr<ResourceMetadataDB> resource_metadata_db_; 334 scoped_ptr<ResourceMetadataDB> resource_metadata_db_;
304 335
305 ResourceMap resource_map_; 336 ResourceMap resource_map_;
306 337
307 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto. 338 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto.
308 339
309 base::Time last_serialized_; 340 base::Time last_serialized_;
310 size_t serialized_size_; 341 size_t serialized_size_;
311 int64 largest_changestamp_; // Stored in the serialized proto. 342 int64 largest_changestamp_; // Stored in the serialized proto.
312 bool loaded_; 343 bool loaded_;
313 344
314 // This should remain the last member so it'll be destroyed first and 345 // This should remain the last member so it'll be destroyed first and
315 // invalidate its weak pointers before other members are destroyed. 346 // invalidate its weak pointers before other members are destroyed.
316 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; 347 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_;
317 348
318 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); 349 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata);
319 }; 350 };
320 351
321 } // namespace drive 352 } // namespace drive
322 353
323 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 354 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system_unittest.cc ('k') | chrome/browser/chromeos/drive/drive_resource_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698