OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_BROWSER_BLOB_CONTENT_URL_STREAM_READER_ANDROID_H_ |
| 6 #define WEBKIT_BROWSER_BLOB_CONTENT_URL_STREAM_READER_ANDROID_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/platform_file.h" |
| 14 #include "base/time/time.h" |
| 15 #include "url/gurl.h" |
| 16 #include "webkit/browser/blob/file_stream_reader.h" |
| 17 #include "webkit/browser/webkit_storage_browser_export.h" |
| 18 |
| 19 namespace base { |
| 20 class TaskRunner; |
| 21 } |
| 22 |
| 23 namespace net { |
| 24 class FileStream; |
| 25 } |
| 26 |
| 27 namespace webkit_blob { |
| 28 |
| 29 // A thin wrapper of net::FileStream to handle content url reading. |
| 30 class WEBKIT_STORAGE_BROWSER_EXPORT ContentUrlStreamReader |
| 31 : public NON_EXPORTED_BASE(FileStreamReader) { |
| 32 public: |
| 33 virtual ~ContentUrlStreamReader(); |
| 34 |
| 35 // FileStreamReader overrides. |
| 36 virtual int Read(net::IOBuffer* buf, int buf_len, |
| 37 const net::CompletionCallback& callback) OVERRIDE; |
| 38 virtual int64 GetLength( |
| 39 const net::Int64CompletionCallback& callback) OVERRIDE; |
| 40 |
| 41 private: |
| 42 friend class FileStreamReader; |
| 43 |
| 44 ContentUrlStreamReader(base::TaskRunner* task_runner, |
| 45 const GURL& content_url_, |
| 46 int64 initial_offset); |
| 47 |
| 48 // Methods to for handling file operations. |
| 49 int Open(const net::CompletionCallback& callback); |
| 50 void DidOpenContentUrl( |
| 51 const net::CompletionCallback& callback, |
| 52 int result); |
| 53 void DidOpenForRead( |
| 54 net::IOBuffer* buf, |
| 55 int buf_len, |
| 56 const net::CompletionCallback& callback, |
| 57 int open_result); |
| 58 void DidSeekContentUrl( |
| 59 const net::CompletionCallback& callback, |
| 60 int64 seek_result); |
| 61 |
| 62 scoped_refptr<base::TaskRunner> task_runner_; |
| 63 const GURL content_url_; |
| 64 const int64 initial_offset_; |
| 65 scoped_ptr<net::FileStream> stream_impl_; |
| 66 base::WeakPtrFactory<ContentUrlStreamReader> weak_factory_; |
| 67 }; |
| 68 |
| 69 } // namespace webkit_blob |
| 70 |
| 71 #endif // WEBKIT_BROWSER_BLOB_CONTENT_URL_STREAM_READER_ANDROID_H_ |
OLD | NEW |