OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef WEBKIT_BLOB_DELETABLE_FILE_REFERENCE_H_ | |
6 #define WEBKIT_BLOB_DELETABLE_FILE_REFERENCE_H_ | |
7 #pragma once | |
8 | |
9 #include "base/file_path.h" | |
10 #include "base/ref_counted.h" | |
11 | |
12 namespace base { | |
13 class MessageLoopProxy; | |
14 } | |
15 | |
16 namespace webkit_blob { | |
17 | |
18 // A refcounted wrapper around a FilePath that schedules the file | |
19 // to be deleted upon final release. | |
20 class DeletableFileReference : public base::RefCounted<DeletableFileReference> { | |
21 public: | |
22 // Returns a DeletableFileReference for the given path, if no reference | |
23 // for this path exists returns NULL. | |
24 static scoped_refptr<DeletableFileReference> Get(const FilePath& path); | |
25 | |
26 // Returns a DeletableFileReference for the given path, creating a new | |
27 // reference if none yet exists. | |
28 static scoped_refptr<DeletableFileReference> GetOrCreate( | |
29 const FilePath& path, base::MessageLoopProxy* file_thread); | |
30 | |
31 // The full file path. | |
32 const FilePath& path() const { return path_; } | |
33 | |
34 private: | |
35 friend class base::RefCounted<DeletableFileReference>; | |
36 | |
37 DeletableFileReference( | |
38 const FilePath& path, base::MessageLoopProxy* file_thread); | |
39 ~DeletableFileReference(); | |
40 | |
41 const FilePath path_; | |
42 scoped_refptr<base::MessageLoopProxy> file_thread_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(DeletableFileReference); | |
45 }; | |
46 | |
47 } // namespace webkit_blob | |
48 | |
49 #endif // BASE_DELETABLE_FILE_REFERENCE_H_ | |
OLD | NEW |