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

Unified Diff: webkit/blob/shareable_file_reference.h

Issue 14261015: Add ScopedFile class which supports scope-out deletion and/or callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: webkit/blob/shareable_file_reference.h
diff --git a/webkit/blob/shareable_file_reference.h b/webkit/blob/shareable_file_reference.h
index 1eaff08423d2d5ce58e254c63cc44a9976e25b24..5c53b552d4590253c4bdc0cd0e0b0c6bef40f3fd 100644
--- a/webkit/blob/shareable_file_reference.h
+++ b/webkit/blob/shareable_file_reference.h
@@ -7,14 +7,7 @@
#include <vector>
-#include "base/callback.h"
-#include "base/files/file_path.h"
-#include "base/memory/ref_counted.h"
-#include "webkit/storage/webkit_storage_export.h"
-
-namespace base {
-class TaskRunner;
-}
+#include "webkit/blob/scoped_file.h"
namespace webkit_blob {
@@ -25,7 +18,7 @@ namespace webkit_blob {
class WEBKIT_STORAGE_EXPORT ShareableFileReference
: public base::RefCounted<ShareableFileReference> {
public:
- typedef base::Callback<void(const base::FilePath&)> FinalReleaseCallback;
+ typedef ScopedFile::ScopeOutCallback FinalReleaseCallback;
enum FinalReleasePolicy {
DELETE_ON_FINAL_RELEASE,
@@ -38,35 +31,35 @@ class WEBKIT_STORAGE_EXPORT ShareableFileReference
// Returns a ShareableFileReference for the given path, creating a new
// reference if none yet exists. If there's a pre-existing reference for
- // the path, the deletable parameter of this method is ignored.
+ // the path, the policy parameter of this method is ignored.
static scoped_refptr<ShareableFileReference> GetOrCreate(
const base::FilePath& path,
FinalReleasePolicy policy,
base::TaskRunner* file_task_runner);
- // The full file path.
- const base::FilePath& path() const { return path_; }
+ // Returns a ShareableFileReference for the given path of the |scoped_file|,
+ // creating a new reference if none yet exists. The ownership of |scoped_file|
+ // is passed to this reference.
+ // If there's a pre-existing reference for the path, the scope out policy
+ // of the given |scoped_file| is ignored.
+ static scoped_refptr<ShareableFileReference> GetOrCreate(
+ ScopedFile scoped_file);
- // Whether it's to be deleted on final release.
- FinalReleasePolicy final_release_policy() const {
- return final_release_policy_;
- }
+ // The full file path.
+ const base::FilePath& path() const { return scoped_file_.path(); }
+ // The |callback| is fired when the final reference of this instance
+ // is released. If release policy is DELETE_ON_FINAL_RELEASE the
+ // callback(s) is/are called before the deletion is scheduled.
michaeln 2013/04/22 21:07:03 is the latter part of the comment is strictly true
kinuko 2013/04/23 06:31:29 Updated the comment.
void AddFinalReleaseCallback(const FinalReleaseCallback& callback);
private:
friend class base::RefCounted<ShareableFileReference>;
- ShareableFileReference(
- const base::FilePath& path,
- FinalReleasePolicy policy,
- base::TaskRunner* file_task_runner);
+ ShareableFileReference(ScopedFile scoped_file);
~ShareableFileReference();
- const base::FilePath path_;
- const FinalReleasePolicy final_release_policy_;
- const scoped_refptr<base::TaskRunner> file_task_runner_;
- std::vector<FinalReleaseCallback> final_release_callbacks_;
+ ScopedFile scoped_file_;
DISALLOW_COPY_AND_ASSIGN(ShareableFileReference);
};

Powered by Google App Engine
This is Rietveld 408576698