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

Side by Side Diff: webkit/blob/shareable_file_reference.h

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 (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 WEBKIT_BLOB_SHAREABLE_FILE_REFERENCE_H_ 5 #ifndef WEBKIT_BLOB_SHAREABLE_FILE_REFERENCE_H_
6 #define WEBKIT_BLOB_SHAREABLE_FILE_REFERENCE_H_ 6 #define WEBKIT_BLOB_SHAREABLE_FILE_REFERENCE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "webkit/storage/webkit_storage_export.h" 13 #include "webkit/storage/webkit_storage_export.h"
14 14
15 namespace base { 15 namespace base {
16 class TaskRunner; 16 class TaskRunner;
17 } 17 }
18 18
19 namespace webkit_blob { 19 namespace webkit_blob {
20 20
21 // A refcounted wrapper around a FilePath that can optionally schedule 21 // A refcounted wrapper around a FilePath that can optionally schedule
22 // the file to be deleted upon final release and/or to notify a consumer 22 // the file to be deleted upon final release and/or to notify a consumer
23 // when final release occurs. This class is single-threaded and should 23 // when final release occurs. This class is single-threaded and should
24 // only be invoked on the IO thread in chrome. 24 // only be invoked on the IO thread in chrome.
25 class WEBKIT_STORAGE_EXPORT ShareableFileReference 25 class WEBKIT_STORAGE_EXPORT ShareableFileReference
26 : public base::RefCounted<ShareableFileReference> { 26 : public base::RefCounted<ShareableFileReference> {
27 public: 27 public:
28 typedef base::Callback<void(const FilePath&)> FinalReleaseCallback; 28 typedef base::Callback<void(const base::FilePath&)> FinalReleaseCallback;
29 29
30 enum FinalReleasePolicy { 30 enum FinalReleasePolicy {
31 DELETE_ON_FINAL_RELEASE, 31 DELETE_ON_FINAL_RELEASE,
32 DONT_DELETE_ON_FINAL_RELEASE, 32 DONT_DELETE_ON_FINAL_RELEASE,
33 }; 33 };
34 34
35 // Returns a ShareableFileReference for the given path, if no reference 35 // Returns a ShareableFileReference for the given path, if no reference
36 // for this path exists returns NULL. 36 // for this path exists returns NULL.
37 static scoped_refptr<ShareableFileReference> Get(const FilePath& path); 37 static scoped_refptr<ShareableFileReference> Get(const base::FilePath& path);
38 38
39 // Returns a ShareableFileReference for the given path, creating a new 39 // Returns a ShareableFileReference for the given path, creating a new
40 // reference if none yet exists. If there's a pre-existing reference for 40 // reference if none yet exists. If there's a pre-existing reference for
41 // the path, the deletable parameter of this method is ignored. 41 // the path, the deletable parameter of this method is ignored.
42 static scoped_refptr<ShareableFileReference> GetOrCreate( 42 static scoped_refptr<ShareableFileReference> GetOrCreate(
43 const FilePath& path, 43 const base::FilePath& path,
44 FinalReleasePolicy policy, 44 FinalReleasePolicy policy,
45 base::TaskRunner* file_task_runner); 45 base::TaskRunner* file_task_runner);
46 46
47 // The full file path. 47 // The full file path.
48 const FilePath& path() const { return path_; } 48 const base::FilePath& path() const { return path_; }
49 49
50 // Whether it's to be deleted on final release. 50 // Whether it's to be deleted on final release.
51 FinalReleasePolicy final_release_policy() const { 51 FinalReleasePolicy final_release_policy() const {
52 return final_release_policy_; 52 return final_release_policy_;
53 } 53 }
54 54
55 void AddFinalReleaseCallback(const FinalReleaseCallback& callback); 55 void AddFinalReleaseCallback(const FinalReleaseCallback& callback);
56 56
57 private: 57 private:
58 friend class base::RefCounted<ShareableFileReference>; 58 friend class base::RefCounted<ShareableFileReference>;
59 59
60 ShareableFileReference( 60 ShareableFileReference(
61 const FilePath& path, 61 const base::FilePath& path,
62 FinalReleasePolicy policy, 62 FinalReleasePolicy policy,
63 base::TaskRunner* file_task_runner); 63 base::TaskRunner* file_task_runner);
64 ~ShareableFileReference(); 64 ~ShareableFileReference();
65 65
66 const FilePath path_; 66 const base::FilePath path_;
67 const FinalReleasePolicy final_release_policy_; 67 const FinalReleasePolicy final_release_policy_;
68 const scoped_refptr<base::TaskRunner> file_task_runner_; 68 const scoped_refptr<base::TaskRunner> file_task_runner_;
69 std::vector<FinalReleaseCallback> final_release_callbacks_; 69 std::vector<FinalReleaseCallback> final_release_callbacks_;
70 70
71 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference); 71 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference);
72 }; 72 };
73 73
74 } // namespace webkit_blob 74 } // namespace webkit_blob
75 75
76 #endif // WEBKIT_BLOB_SHAREABLE_FILE_REFERENCE_H_ 76 #endif // WEBKIT_BLOB_SHAREABLE_FILE_REFERENCE_H_
OLDNEW
« no previous file with comments | « webkit/blob/local_file_stream_reader_unittest.cc ('k') | webkit/blob/shareable_file_reference.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698