OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "storage/browser/blob/blob_data_handle.h" | 5 #include "storage/browser/blob/blob_data_handle.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 return make_scoped_ptr(FileStreamReader::CreateForLocalFile( | 40 return make_scoped_ptr(FileStreamReader::CreateForLocalFile( |
41 task_runner, file_path, initial_offset, expected_modification_time)); | 41 task_runner, file_path, initial_offset, expected_modification_time)); |
42 } | 42 } |
43 | 43 |
44 scoped_ptr<FileStreamReader> CreateFileStreamReader( | 44 scoped_ptr<FileStreamReader> CreateFileStreamReader( |
45 const GURL& filesystem_url, | 45 const GURL& filesystem_url, |
46 int64_t offset, | 46 int64_t offset, |
47 int64_t max_bytes_to_read, | 47 int64_t max_bytes_to_read, |
48 const base::Time& expected_modification_time) override { | 48 const base::Time& expected_modification_time) override { |
49 return file_system_context_->CreateFileStreamReader( | 49 return file_system_context_->CreateFileStreamReader( |
50 storage::FileSystemURL( | 50 storage::FileSystemURL(file_system_context_->CrackURL(filesystem_url)), |
51 file_system_context_->CrackURL( | 51 offset, max_bytes_to_read, expected_modification_time); |
52 filesystem_url)), | |
53 offset, max_bytes_to_read, | |
54 expected_modification_time) | |
55 .Pass(); | |
56 } | 52 } |
57 | 53 |
58 private: | 54 private: |
59 scoped_refptr<FileSystemContext> file_system_context_; | 55 scoped_refptr<FileSystemContext> file_system_context_; |
60 DISALLOW_COPY_AND_ASSIGN(FileStreamReaderProviderImpl); | 56 DISALLOW_COPY_AND_ASSIGN(FileStreamReaderProviderImpl); |
61 }; | 57 }; |
62 | 58 |
63 } // namespace | 59 } // namespace |
64 | 60 |
65 BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared( | 61 BlobDataHandle::BlobDataHandleShared::BlobDataHandleShared( |
(...skipping 12 matching lines...) Expand all Loading... |
78 FileSystemContext* file_system_context, | 74 FileSystemContext* file_system_context, |
79 base::SequencedTaskRunner* file_task_runner) const { | 75 base::SequencedTaskRunner* file_task_runner) const { |
80 return scoped_ptr<BlobReader>(new BlobReader( | 76 return scoped_ptr<BlobReader>(new BlobReader( |
81 this, scoped_ptr<BlobReader::FileStreamReaderProvider>( | 77 this, scoped_ptr<BlobReader::FileStreamReaderProvider>( |
82 new FileStreamReaderProviderImpl(file_system_context)), | 78 new FileStreamReaderProviderImpl(file_system_context)), |
83 file_task_runner)); | 79 file_task_runner)); |
84 } | 80 } |
85 | 81 |
86 scoped_ptr<BlobDataSnapshot> | 82 scoped_ptr<BlobDataSnapshot> |
87 BlobDataHandle::BlobDataHandleShared::CreateSnapshot() const { | 83 BlobDataHandle::BlobDataHandleShared::CreateSnapshot() const { |
88 return context_->CreateSnapshot(uuid_).Pass(); | 84 return context_->CreateSnapshot(uuid_); |
89 } | 85 } |
90 | 86 |
91 BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() { | 87 BlobDataHandle::BlobDataHandleShared::~BlobDataHandleShared() { |
92 if (context_.get()) | 88 if (context_.get()) |
93 context_->DecrementBlobRefCount(uuid_); | 89 context_->DecrementBlobRefCount(uuid_); |
94 } | 90 } |
95 | 91 |
96 BlobDataHandle::BlobDataHandle(const std::string& uuid, | 92 BlobDataHandle::BlobDataHandle(const std::string& uuid, |
97 const std::string& content_type, | 93 const std::string& content_type, |
98 const std::string& content_disposition, | 94 const std::string& content_disposition, |
(...skipping 15 matching lines...) Expand all Loading... |
114 | 110 |
115 BlobDataHandle::~BlobDataHandle() { | 111 BlobDataHandle::~BlobDataHandle() { |
116 BlobDataHandleShared* raw = shared_.get(); | 112 BlobDataHandleShared* raw = shared_.get(); |
117 raw->AddRef(); | 113 raw->AddRef(); |
118 shared_ = nullptr; | 114 shared_ = nullptr; |
119 io_task_runner_->ReleaseSoon(FROM_HERE, raw); | 115 io_task_runner_->ReleaseSoon(FROM_HERE, raw); |
120 } | 116 } |
121 | 117 |
122 scoped_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const { | 118 scoped_ptr<BlobDataSnapshot> BlobDataHandle::CreateSnapshot() const { |
123 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 119 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
124 return shared_->CreateSnapshot().Pass(); | 120 return shared_->CreateSnapshot(); |
125 } | 121 } |
126 | 122 |
127 const std::string& BlobDataHandle::uuid() const { | 123 const std::string& BlobDataHandle::uuid() const { |
128 return shared_->uuid_; | 124 return shared_->uuid_; |
129 } | 125 } |
130 | 126 |
131 const std::string& BlobDataHandle::content_type() const { | 127 const std::string& BlobDataHandle::content_type() const { |
132 return shared_->content_type_; | 128 return shared_->content_type_; |
133 } | 129 } |
134 | 130 |
135 const std::string& BlobDataHandle::content_disposition() const { | 131 const std::string& BlobDataHandle::content_disposition() const { |
136 return shared_->content_disposition_; | 132 return shared_->content_disposition_; |
137 } | 133 } |
138 | 134 |
139 } // namespace storage | 135 } // namespace storage |
OLD | NEW |