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

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

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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 #include "content/browser/renderer_host/pepper/quota_reservation.h" 5 #include "content/browser/renderer_host/pepper/quota_reservation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "content/public/browser/browser_thread.h" 9 #include "content/public/browser/browser_thread.h"
10 #include "webkit/browser/fileapi/file_system_operation_runner.h" 10 #include "storage/browser/fileapi/file_system_operation_runner.h"
11 #include "webkit/browser/fileapi/quota/open_file_handle.h" 11 #include "storage/browser/fileapi/quota/open_file_handle.h"
12 #include "webkit/browser/fileapi/quota/quota_reservation.h" 12 #include "storage/browser/fileapi/quota/quota_reservation.h"
13 #include "webkit/common/fileapi/file_system_util.h" 13 #include "storage/common/fileapi/file_system_util.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 // static 17 // static
18 scoped_refptr<QuotaReservation> QuotaReservation::Create( 18 scoped_refptr<QuotaReservation> QuotaReservation::Create(
19 scoped_refptr<fileapi::FileSystemContext> file_system_context, 19 scoped_refptr<storage::FileSystemContext> file_system_context,
20 const GURL& origin_url, 20 const GURL& origin_url,
21 fileapi::FileSystemType type) { 21 storage::FileSystemType type) {
22 return scoped_refptr<QuotaReservation>( 22 return scoped_refptr<QuotaReservation>(
23 new QuotaReservation(file_system_context, origin_url, type)); 23 new QuotaReservation(file_system_context, origin_url, type));
24 } 24 }
25 25
26 QuotaReservation::QuotaReservation( 26 QuotaReservation::QuotaReservation(
27 scoped_refptr<fileapi::FileSystemContext> file_system_context, 27 scoped_refptr<storage::FileSystemContext> file_system_context,
28 const GURL& origin_url, 28 const GURL& origin_url,
29 fileapi::FileSystemType file_system_type) 29 storage::FileSystemType file_system_type)
30 : file_system_context_(file_system_context) { 30 : file_system_context_(file_system_context) {
31 quota_reservation_ = 31 quota_reservation_ =
32 file_system_context->CreateQuotaReservationOnFileTaskRunner( 32 file_system_context->CreateQuotaReservationOnFileTaskRunner(
33 origin_url, file_system_type); 33 origin_url, file_system_type);
34 } 34 }
35 35
36 // For unit testing only. 36 // For unit testing only.
37 QuotaReservation::QuotaReservation( 37 QuotaReservation::QuotaReservation(
38 scoped_refptr<fileapi::QuotaReservation> quota_reservation, 38 scoped_refptr<storage::QuotaReservation> quota_reservation,
39 const GURL& /* origin_url */, 39 const GURL& /* origin_url */,
40 fileapi::FileSystemType /* file_system_type */) 40 storage::FileSystemType /* file_system_type */)
41 : quota_reservation_(quota_reservation) {} 41 : quota_reservation_(quota_reservation) {
42 }
42 43
43 QuotaReservation::~QuotaReservation() { 44 QuotaReservation::~QuotaReservation() {
44 // We should have no open files at this point. 45 // We should have no open files at this point.
45 DCHECK(files_.size() == 0); 46 DCHECK(files_.size() == 0);
46 for (FileMap::iterator it = files_.begin(); it != files_.end(); ++it) 47 for (FileMap::iterator it = files_.begin(); it != files_.end(); ++it)
47 delete it->second; 48 delete it->second;
48 } 49 }
49 50
50 int64_t QuotaReservation::OpenFile(int32_t id, 51 int64_t QuotaReservation::OpenFile(int32_t id,
51 const fileapi::FileSystemURL& url) { 52 const storage::FileSystemURL& url) {
52 base::FilePath platform_file_path; 53 base::FilePath platform_file_path;
53 if (file_system_context_) { 54 if (file_system_context_) {
54 base::File::Error error = 55 base::File::Error error =
55 file_system_context_->operation_runner()->SyncGetPlatformPath( 56 file_system_context_->operation_runner()->SyncGetPlatformPath(
56 url, &platform_file_path); 57 url, &platform_file_path);
57 if (error != base::File::FILE_OK) { 58 if (error != base::File::FILE_OK) {
58 NOTREACHED(); 59 NOTREACHED();
59 return 0; 60 return 0;
60 } 61 }
61 } else { 62 } else {
62 // For test. 63 // For test.
63 platform_file_path = url.path(); 64 platform_file_path = url.path();
64 } 65 }
65 66
66 scoped_ptr<fileapi::OpenFileHandle> file_handle = 67 scoped_ptr<storage::OpenFileHandle> file_handle =
67 quota_reservation_->GetOpenFileHandle(platform_file_path); 68 quota_reservation_->GetOpenFileHandle(platform_file_path);
68 std::pair<FileMap::iterator, bool> insert_result = 69 std::pair<FileMap::iterator, bool> insert_result =
69 files_.insert(std::make_pair(id, file_handle.get())); 70 files_.insert(std::make_pair(id, file_handle.get()));
70 if (insert_result.second) { 71 if (insert_result.second) {
71 int64_t max_written_offset = file_handle->GetMaxWrittenOffset(); 72 int64_t max_written_offset = file_handle->GetMaxWrittenOffset();
72 ignore_result(file_handle.release()); 73 ignore_result(file_handle.release());
73 return max_written_offset; 74 return max_written_offset;
74 } 75 }
75 NOTREACHED(); 76 NOTREACHED();
76 return 0; 77 return 0;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 ->RunsTasksOnCurrentThread()) { 134 ->RunsTasksOnCurrentThread()) {
134 file_system_context_->default_file_task_runner()->DeleteSoon(FROM_HERE, 135 file_system_context_->default_file_task_runner()->DeleteSoon(FROM_HERE,
135 this); 136 this);
136 } else { 137 } else {
137 // We're on the right thread to delete, or unit test. 138 // We're on the right thread to delete, or unit test.
138 delete this; 139 delete this;
139 } 140 }
140 } 141 }
141 142
142 } // namespace content 143 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698