| Index: net/base/upload_content_url_element_reader_android.h
|
| diff --git a/net/base/upload_content_url_element_reader_android.h b/net/base/upload_content_url_element_reader_android.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f40d092d235daa9a6d6d97c151b1ef5476362ab1
|
| --- /dev/null
|
| +++ b/net/base/upload_content_url_element_reader_android.h
|
| @@ -0,0 +1,94 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef NET_BASE_UPLOAD_CONTENT_URL_ELEMENT_READER_H_
|
| +#define NET_BASE_UPLOAD_CONTENT_URL_ELEMENT_READER_H_
|
| +
|
| +#include "base/compiler_specific.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "base/time/time.h"
|
| +#include "net/base/upload_element_reader.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace base {
|
| +class TaskRunner;
|
| +}
|
| +
|
| +namespace net {
|
| +
|
| +class FileStream;
|
| +
|
| +// An UploadElementReader implementation for content url.
|
| +class NET_EXPORT UploadContentUrlElementReader : public UploadElementReader {
|
| + public:
|
| + // |task_runner| is used to perform file operations. It must not be NULL.
|
| + UploadContentUrlElementReader(base::TaskRunner* task_runner,
|
| + const GURL& content_url,
|
| + uint64 range_offset,
|
| + uint64 range_length,
|
| + const base::Time& expected_modification_time);
|
| + virtual ~UploadContentUrlElementReader();
|
| +
|
| + const GURL& content_url() const { return content_url_; }
|
| + uint64 range_offset() const { return range_offset_; }
|
| + uint64 range_length() const { return range_length_; }
|
| + const base::Time& expected_modification_time() const {
|
| + return expected_modification_time_;
|
| + }
|
| +
|
| + // UploadElementReader overrides:
|
| + virtual int Init(const CompletionCallback& callback) OVERRIDE;
|
| + virtual uint64 GetContentLength() const OVERRIDE;
|
| + virtual uint64 BytesRemaining() const OVERRIDE;
|
| + virtual int Read(IOBuffer* buf,
|
| + int buf_length,
|
| + const CompletionCallback& callback) OVERRIDE;
|
| +
|
| + private:
|
| + // Deletes FileStream with |task_runner| to avoid blocking the IO thread.
|
| + // This class is used as a template argument of scoped_ptr.
|
| + class FileStreamDeleter {
|
| + public:
|
| + explicit FileStreamDeleter(base::TaskRunner* task_runner);
|
| + ~FileStreamDeleter();
|
| + void operator() (FileStream* file_stream) const;
|
| +
|
| + private:
|
| + scoped_refptr<base::TaskRunner> task_runner_;
|
| + };
|
| +
|
| + typedef scoped_ptr<FileStream, FileStreamDeleter> ScopedFileStreamPtr;
|
| +
|
| + // Resets this instance to the uninitialized state.
|
| + void Reset();
|
| +
|
| + // This method is used to implement Init().
|
| + void OnInitCompleted(ScopedFileStreamPtr* file_stream,
|
| + uint64* content_length,
|
| + const CompletionCallback& callback,
|
| + int result);
|
| +
|
| + // This method is used to implement Read().
|
| + void OnReadCompleted(ScopedFileStreamPtr file_stream,
|
| + const CompletionCallback& callback,
|
| + int result);
|
| +
|
| + scoped_refptr<base::TaskRunner> task_runner_;
|
| + const GURL& content_url_;
|
| + const uint64 range_offset_;
|
| + const uint64 range_length_;
|
| + const base::Time expected_modification_time_;
|
| + ScopedFileStreamPtr file_stream_;
|
| + uint64 content_length_;
|
| + uint64 bytes_remaining_;
|
| + base::WeakPtrFactory<UploadContentUrlElementReader> weak_ptr_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(UploadContentUrlElementReader);
|
| +};
|
| +
|
| +} // namespace net
|
| +
|
| +#endif // NET_BASE_UPLOAD_CONTENT_URL_ELEMENT_READER_H_
|
|
|