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

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: merge conflicts + feedback 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // If |error| is not DRIVE_FILE_OK, |entry_proto| is set to NULL. 87 // If |error| is not DRIVE_FILE_OK, |entry_proto| is set to NULL.
87 // 88 //
88 // |drive_file_path| parameter is provided as DriveEntryProto does not contain 89 // |drive_file_path| parameter is provided as DriveEntryProto does not contain
89 // the Drive file path (i.e. only contains the base name without parent 90 // the Drive file path (i.e. only contains the base name without parent
90 // directory names). 91 // directory names).
91 typedef base::Callback<void(DriveFileError error, 92 typedef base::Callback<void(DriveFileError error,
92 const FilePath& drive_file_path, 93 const FilePath& drive_file_path,
93 scoped_ptr<DriveEntryProto> entry_proto)> 94 scoped_ptr<DriveEntryProto> entry_proto)>
94 GetEntryInfoWithFilePathCallback; 95 GetEntryInfoWithFilePathCallback;
95 96
97 // Used to get a set of changed directories for feed processing.
98 typedef base::Callback<void(const std::set<FilePath>&)>
99 GetChildDirectoriesCallback;
100
96 // This is a part of EntryInfoPairResult. 101 // This is a part of EntryInfoPairResult.
97 struct EntryInfoResult { 102 struct EntryInfoResult {
98 EntryInfoResult(); 103 EntryInfoResult();
99 ~EntryInfoResult(); 104 ~EntryInfoResult();
100 105
101 FilePath path; 106 FilePath path;
102 DriveFileError error; 107 DriveFileError error;
103 scoped_ptr<DriveEntryProto> proto; 108 scoped_ptr<DriveEntryProto> proto;
104 }; 109 };
105 110
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // |first_path| is not found, this function does not try to get the 226 // |first_path| is not found, this function does not try to get the
222 // entry of |second_path|. 227 // entry of |second_path|.
223 // 228 //
224 // Must be called from UI thread. |callback| is run on UI thread. 229 // Must be called from UI thread. |callback| is run on UI thread.
225 // |callback| must not be null. 230 // |callback| must not be null.
226 void GetEntryInfoPairByPaths( 231 void GetEntryInfoPairByPaths(
227 const FilePath& first_path, 232 const FilePath& first_path,
228 const FilePath& second_path, 233 const FilePath& second_path,
229 const GetEntryInfoPairCallback& callback); 234 const GetEntryInfoPairCallback& callback);
230 235
231 // Replaces a file entry with the same resource id as |doc_entry| by deleting 236 // Refreshes a drive entry with the same resource id as |entry_proto|.
232 // the existing entry, creating a new DriveFile from |doc_entry|, and adding 237 // |callback| is run with the error, file path and proto of the entry.
233 // it to the parent of the old entry. For directories, this just returns the 238 // |callback| must not be null.
234 // existing directory proto. |callback| is run with the error, file path and 239 void RefreshEntryProto(const DriveEntryProto& entry_proto,
235 // proto of the entry. |callback| must not be null. 240 const GetEntryInfoWithFilePathCallback& callback);
241
242 // Refresh a drive entry with resource_id that matches that of |doc_entry|,
243 // with |doc_entry|.
244 // |callback| must not be null.
245 // TODO(achuith): Deprecate this in favor of RefreshEntryProto above.
236 void RefreshFile(scoped_ptr<google_apis::DocumentEntry> doc_entry, 246 void RefreshFile(scoped_ptr<google_apis::DocumentEntry> doc_entry,
237 const GetEntryInfoWithFilePathCallback& callback); 247 const GetEntryInfoWithFilePathCallback& callback);
238 248
239 // Removes all child files of |directory| and replaces them with 249 // Removes all child files of |directory| and replaces them with
240 // |entry_proto_map|. |callback| is called with the directory path. 250 // |entry_proto_map|. |callback| is called with the directory path.
241 // |callback| must not be null. 251 // |callback| must not be null.
242 void RefreshDirectory(const std::string& directory_resource_id, 252 void RefreshDirectory(const std::string& directory_resource_id,
243 const DriveEntryProtoMap& entry_proto_map, 253 const DriveEntryProtoMap& entry_proto_map,
244 const FileMoveCallback& callback); 254 const FileMoveCallback& callback);
245 255
256 // Add |entry_proto| to the metadata tree.
257 // |callback| must not be null.
258 void AddEntryToParent(const DriveEntryProto& entry_proto,
259 const FileMoveCallback& callback);
260
261 // Recursively get child directories of entry pointed to by |resource_id|.
262 void GetChildDirectories(
263 const std::string& resource_id,
264 const GetChildDirectoriesCallback& changed_dirs_callback);
265
246 // Moves all child entries from the directory represented by 266 // Moves all child entries from the directory represented by
247 // |source_resource_id| to the directory respresented by 267 // |source_resource_id| to the directory respresented by
248 // |destination_resource_id|. |callback| must not be null. 268 // |destination_resource_id|. |callback| must not be null.
269 // TODO(achuith): Delete this.
249 void TakeOverEntries(const std::string& source_resource_id, 270 void TakeOverEntries(const std::string& source_resource_id,
250 const std::string& destination_resource_id, 271 const std::string& destination_resource_id,
251 const FileMoveCallback& callback); 272 const FileMoveCallback& callback);
252 273
253 // Serializes/Parses to/from string via proto classes. 274 // Serializes/Parses to/from string via proto classes.
254 void SerializeToString(std::string* serialized_proto) const; 275 void SerializeToString(std::string* serialized_proto) const;
255 bool ParseFromString(const std::string& serialized_proto); 276 bool ParseFromString(const std::string& serialized_proto);
256 277
257 // Restores from and saves to database, calling |callback| asynchronously. 278 // Restores from and saves to database, calling |callback| asynchronously.
258 // |callback| must not be null. 279 // |callback| must not be null.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been 313 // Continues with GetIntroInfoPairByPaths after the second DriveEntry has been
293 // asynchronously fetched. 314 // asynchronously fetched.
294 void GetEntryInfoPairByPathsAfterGetSecond( 315 void GetEntryInfoPairByPathsAfterGetSecond(
295 const FilePath& second_path, 316 const FilePath& second_path,
296 const GetEntryInfoPairCallback& callback, 317 const GetEntryInfoPairCallback& callback,
297 scoped_ptr<EntryInfoPairResult> result, 318 scoped_ptr<EntryInfoPairResult> result,
298 DriveFileError error, 319 DriveFileError error,
299 scoped_ptr<DriveEntryProto> entry_proto); 320 scoped_ptr<DriveEntryProto> entry_proto);
300 321
301 // Searches for |file_path| synchronously. 322 // Searches for |file_path| synchronously.
302 // TODO(satorux): Replace this with an async version crbug.com/137160
303 DriveEntry* FindEntryByPathSync(const FilePath& file_path); 323 DriveEntry* FindEntryByPathSync(const FilePath& file_path);
304 324
325 // Helper function to add |entry_proto| as a child to |directory|.
326 // |callback| must not be null.
327 void AddEntryToDirectoryInternal(DriveDirectory* directory,
328 const DriveEntryProto& entry_proto,
329 const FileMoveCallback& callback);
330
331 // Helper function to get a parent directory given |parent_resource_id|.
332 // Returns root if |parent_resource_id| is empty. Returns NULL if
333 // |parent_resource_id| is not empty and the corresponding entry is not a
334 // directory.
335 DriveDirectory* GetParent(const std::string& parent_resource_id);
336
305 // Private data members. 337 // Private data members.
306 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; 338 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
307 scoped_ptr<ResourceMetadataDB> resource_metadata_db_; 339 scoped_ptr<ResourceMetadataDB> resource_metadata_db_;
308 340
309 ResourceMap resource_map_; 341 ResourceMap resource_map_;
310 342
311 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto. 343 scoped_ptr<DriveDirectory> root_; // Stored in the serialized proto.
312 344
313 base::Time last_serialized_; 345 base::Time last_serialized_;
314 size_t serialized_size_; 346 size_t serialized_size_;
315 int64 largest_changestamp_; // Stored in the serialized proto. 347 int64 largest_changestamp_; // Stored in the serialized proto.
316 bool loaded_; 348 bool loaded_;
317 349
318 // This should remain the last member so it'll be destroyed first and 350 // This should remain the last member so it'll be destroyed first and
319 // invalidate its weak pointers before other members are destroyed. 351 // invalidate its weak pointers before other members are destroyed.
320 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; 352 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_;
321 353
322 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); 354 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata);
323 }; 355 };
324 356
325 } // namespace drive 357 } // namespace drive
326 358
327 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 359 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_feed_processor.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