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

Side by Side Diff: content/browser/renderer_host/pepper/quota_reservation.h

Issue 131043002: [Pepper] Use platform path for QuotaReservation::GetOpenFileHandle (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: suppress DCHECK failure Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CONTENT_BROWSER_RENDERER_HOST_PEPPER_QUOTA_RESERVATION_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_PEPPER_QUOTA_RESERVATION_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_QUOTA_RESERVATION_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_PEPPER_QUOTA_RESERVATION_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/platform_file.h" 12 #include "base/platform_file.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "ppapi/c/pp_stdint.h" // For int64_t on Windows. 14 #include "ppapi/c/pp_stdint.h" // For int64_t on Windows.
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 #include "webkit/browser/fileapi/file_system_context.h" 16 #include "webkit/browser/fileapi/file_system_context.h"
17 17
18 namespace base {
19 class FilePath;
20 }
21
22 namespace fileapi { 18 namespace fileapi {
19 class FileSystemURL;
23 class OpenFileHandle; 20 class OpenFileHandle;
24 class QuotaReservation; 21 class QuotaReservation;
25 } 22 }
26 23
27 namespace content { 24 namespace content {
28 25
29 struct QuotaReservationDeleter; 26 struct QuotaReservationDeleter;
30 27
31 // This class holds a QuotaReservation and manages OpenFileHandles for checking 28 // This class holds a QuotaReservation and manages OpenFileHandles for checking
32 // quota. It should be created, used, and destroyed on a FileSystemContext's 29 // quota. It should be created, used, and destroyed on a FileSystemContext's
33 // default_file_task_runner() instance. This is a RefCountedThreadSafe object 30 // default_file_task_runner() instance. This is a RefCountedThreadSafe object
34 // because it needs to be passed to the file thread and kept alive during 31 // because it needs to be passed to the file thread and kept alive during
35 // potentially long-running quota operations. 32 // potentially long-running quota operations.
36 class CONTENT_EXPORT QuotaReservation 33 class CONTENT_EXPORT QuotaReservation
37 : public base::RefCountedThreadSafe<QuotaReservation, 34 : public base::RefCountedThreadSafe<QuotaReservation,
38 QuotaReservationDeleter> { 35 QuotaReservationDeleter> {
39 public: 36 public:
40 // Static method to facilitate construction on the file task runner. 37 // Static method to facilitate construction on the file task runner.
41 static scoped_refptr<QuotaReservation> Create( 38 static scoped_refptr<QuotaReservation> Create(
42 scoped_refptr<fileapi::FileSystemContext> file_system_context, 39 scoped_refptr<fileapi::FileSystemContext> file_system_context,
43 const GURL& origin_url, 40 const GURL& origin_url,
44 fileapi::FileSystemType file_system_type); 41 fileapi::FileSystemType file_system_type);
45 42
46 // Opens a file with the given id and path and returns its current size. 43 // Opens a file with the given id and path and returns its current size.
47 int64_t OpenFile(int32_t id, const base::FilePath& file_path); 44 int64_t OpenFile(int32_t id, const fileapi::FileSystemURL& url);
48 // Closes the file opened by OpenFile with the given id. 45 // Closes the file opened by OpenFile with the given id.
49 void CloseFile(int32_t id, int64_t max_written_offset); 46 void CloseFile(int32_t id, int64_t max_written_offset);
50 // Refreshes the quota reservation to a new amount. A map that associates file 47 // Refreshes the quota reservation to a new amount. A map that associates file
51 // ids with maximum written offsets is provided as input. The callback will 48 // ids with maximum written offsets is provided as input. The callback will
52 // receive a similar map with the updated file sizes. 49 // receive a similar map with the updated file sizes.
53 typedef std::map<int32_t, int64_t> OffsetMap; 50 typedef std::map<int32_t, int64_t> OffsetMap;
54 typedef base::Callback<void(int64_t, const OffsetMap&)> ReserveQuotaCallback; 51 typedef base::Callback<void(int64_t, const OffsetMap&)> ReserveQuotaCallback;
55 void ReserveQuota(int64_t amount, 52 void ReserveQuota(int64_t amount,
56 const OffsetMap& max_written_offsets, 53 const OffsetMap& max_written_offsets,
57 const ReserveQuotaCallback& callback); 54 const ReserveQuotaCallback& callback);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 93
97 struct QuotaReservationDeleter { 94 struct QuotaReservationDeleter {
98 static void Destruct(const QuotaReservation* quota_reservation) { 95 static void Destruct(const QuotaReservation* quota_reservation) {
99 quota_reservation->DeleteOnCorrectThread(); 96 quota_reservation->DeleteOnCorrectThread();
100 } 97 }
101 }; 98 };
102 99
103 } // namespace content 100 } // namespace content
104 101
105 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_QUOTA_RESERVATION_H_ 102 #endif // CONTENT_BROWSER_RENDERER_HOST_PEPPER_QUOTA_RESERVATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698