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

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

Issue 12706012: chromeos: Destruct DriveResourceMetadata on the blocking pool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add note Created 7 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_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 <set>
10 #include <string> 10 #include <string>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 typedef base::Callback<void(scoped_ptr<EntryInfoPairResult> pair_result)> 130 typedef base::Callback<void(scoped_ptr<EntryInfoPairResult> pair_result)>
131 GetEntryInfoPairCallback; 131 GetEntryInfoPairCallback;
132 132
133 // Storage for Drive Metadata. 133 // Storage for Drive Metadata.
134 class DriveResourceMetadata { 134 class DriveResourceMetadata {
135 public: 135 public:
136 // |root_resource_id| is the resource id for the root directory. 136 // |root_resource_id| is the resource id for the root directory.
137 DriveResourceMetadata( 137 DriveResourceMetadata(
138 const std::string& root_resource_id, 138 const std::string& root_resource_id,
139 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner); 139 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
140 virtual ~DriveResourceMetadata(); 140
141 // Destroys this object. This method posts a task to |blocking_task_runner_|
142 // to safely delete this object.
143 void Destroy();
141 144
142 // True if the file system feed is loaded from the cache or from the server. 145 // True if the file system feed is loaded from the cache or from the server.
143 bool loaded() const { return loaded_; } 146 bool loaded() const { return loaded_; }
144 void set_loaded(bool loaded) { loaded_ = loaded; } 147 void set_loaded(bool loaded) { loaded_ = loaded; }
145 148
146 // Largest change timestamp that was the source of content for the current 149 // Largest change timestamp that was the source of content for the current
147 // state of the root directory. 150 // state of the root directory.
148 void GetLargestChangestamp(const GetChangestampCallback& callback); 151 void GetLargestChangestamp(const GetChangestampCallback& callback);
149 void SetLargestChangestamp(int64 value, 152 void SetLargestChangestamp(int64 value,
150 const FileOperationCallback& callback); 153 const FileOperationCallback& callback);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Saves metadata to the specified directory when appropriate. 230 // Saves metadata to the specified directory when appropriate.
228 void MaybeSave(const base::FilePath& directory_path); 231 void MaybeSave(const base::FilePath& directory_path);
229 232
230 // Loads metadata from the specified directory. 233 // Loads metadata from the specified directory.
231 void Load(const base::FilePath& directory_path, 234 void Load(const base::FilePath& directory_path,
232 const FileOperationCallback& callback); 235 const FileOperationCallback& callback);
233 236
234 private: 237 private:
235 friend class DriveResourceMetadataTest; 238 friend class DriveResourceMetadataTest;
236 239
240 // Note: Use Destroy() to delete this object.
241 virtual ~DriveResourceMetadata();
242
243 // Used to implement Destroy().
244 void DestroyOnBlockingPool();
245
237 // Clears root_ and the resource map. 246 // Clears root_ and the resource map.
238 void ClearRoot(); 247 void ClearRoot();
239 248
240 // Continues with GetEntryInfoPairByPaths after the first DriveEntry has been 249 // Continues with GetEntryInfoPairByPaths after the first DriveEntry has been
241 // asynchronously fetched. This fetches the second DriveEntry only if the 250 // asynchronously fetched. This fetches the second DriveEntry only if the
242 // first was found. 251 // first was found.
243 void GetEntryInfoPairByPathsAfterGetFirst( 252 void GetEntryInfoPairByPathsAfterGetFirst(
244 const base::FilePath& first_path, 253 const base::FilePath& first_path,
245 const base::FilePath& second_path, 254 const base::FilePath& second_path,
246 const GetEntryInfoPairCallback& callback, 255 const GetEntryInfoPairCallback& callback,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // This should remain the last member so it'll be destroyed first and 331 // This should remain the last member so it'll be destroyed first and
323 // invalidate its weak pointers before other members are destroyed. 332 // invalidate its weak pointers before other members are destroyed.
324 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_; 333 base::WeakPtrFactory<DriveResourceMetadata> weak_ptr_factory_;
325 334
326 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata); 335 DISALLOW_COPY_AND_ASSIGN(DriveResourceMetadata);
327 }; 336 };
328 337
329 } // namespace drive 338 } // namespace drive
330 339
331 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_ 340 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_RESOURCE_METADATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/drive_file_system_util.h ('k') | chrome/browser/chromeos/drive/drive_resource_metadata.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698