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

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

Issue 524983002: Move fileapi-related files from webkit/common/ to storage/common/ and set up redirect headers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 6 years, 3 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
« no previous file with comments | « webkit/common/blob/scoped_file.cc ('k') | webkit/common/blob/shareable_file_reference.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_ 5 #include "storage/common/blob/shareable_file_reference.h"
6 #define WEBKIT_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_
7
8 #include <vector>
9
10 #include "webkit/common/blob/scoped_file.h"
11
12 namespace storage {
13
14 // ShareableFileReference allows consumers to share FileReference for the
15 // same path if it already exists in its internal map.
16 // This class is non-thread-safe and all methods must be called on a single
17 // thread.
18 class STORAGE_COMMON_EXPORT ShareableFileReference
19 : public base::RefCounted<ShareableFileReference> {
20 public:
21 typedef ScopedFile::ScopeOutCallback FinalReleaseCallback;
22
23 enum FinalReleasePolicy {
24 DELETE_ON_FINAL_RELEASE = ScopedFile::DELETE_ON_SCOPE_OUT,
25 DONT_DELETE_ON_FINAL_RELEASE = ScopedFile::DONT_DELETE_ON_SCOPE_OUT,
26 };
27
28 // Returns a ShareableFileReference for the given path, if no reference
29 // for this path exists returns NULL.
30 static scoped_refptr<ShareableFileReference> Get(const base::FilePath& path);
31
32 // Returns a ShareableFileReference for the given path, creating a new
33 // reference if none yet exists. If there's a pre-existing reference for
34 // the path, the policy parameter of this method is ignored.
35 static scoped_refptr<ShareableFileReference> GetOrCreate(
36 const base::FilePath& path,
37 FinalReleasePolicy policy,
38 base::TaskRunner* file_task_runner);
39
40 // Returns a ShareableFileReference for the given path of the |scoped_file|,
41 // creating a new reference if none yet exists. The ownership of |scoped_file|
42 // is passed to this reference.
43 // If there's a pre-existing reference for the path, the scope out policy
44 // and scope-out-callbacks of the given |scoped_file| is ignored.
45 // If the given scoped_file has an empty path (e.g. maybe already
46 // released) this returns NULL reference.
47 //
48 // TODO(kinuko): Make sure if this behavior is ok, we could alternatively
49 // merge callbacks to the existing one.
50 static scoped_refptr<ShareableFileReference> GetOrCreate(
51 ScopedFile scoped_file);
52
53 // The full file path.
54 const base::FilePath& path() const { return scoped_file_.path(); }
55
56 // The |callback| is fired when the final reference of this instance
57 // is released. If release policy is DELETE_ON_FINAL_RELEASE the
58 // callback task(s) is/are posted before the deletion is scheduled.
59 void AddFinalReleaseCallback(const FinalReleaseCallback& callback);
60
61 private:
62 friend class base::RefCounted<ShareableFileReference>;
63
64 ShareableFileReference(ScopedFile scoped_file);
65 ~ShareableFileReference();
66
67 ScopedFile scoped_file_;
68
69 DISALLOW_COPY_AND_ASSIGN(ShareableFileReference);
70 };
71
72 } // namespace storage
73
74 #endif // WEBKIT_COMMON_BLOB_SHAREABLE_FILE_REFERENCE_H_
OLDNEW
« no previous file with comments | « webkit/common/blob/scoped_file.cc ('k') | webkit/common/blob/shareable_file_reference.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698