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

Unified Diff: content/browser/android/url_request_content_job.h

Issue 739033003: Support content scheme uri for Chrome on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moving content:// protocol handler to content/browser/android Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/url_request_content_job.h
diff --git a/content/browser/android/url_request_content_job.h b/content/browser/android/url_request_content_job.h
new file mode 100644
index 0000000000000000000000000000000000000000..e03e81588e56affc42943de9ea8857c48045c8ad
--- /dev/null
+++ b/content/browser/android/url_request_content_job.h
@@ -0,0 +1,101 @@
+// Copyright (c) 2014 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 CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_
+#define CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_
+
+#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "content/common/content_export.h"
+#include "net/http/http_byte_range.h"
+#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_job.h"
+
+namespace base {
+class TaskRunner;
+}
+
+namespace file_util {
+struct FileInfo;
+}
+
+namespace net {
+class FileStream;
+}
+
+namespace content {
+
+// A request job that handles reading content URIs
+class CONTENT_EXPORT URLRequestContentJob : public net::URLRequestJob {
+ public:
+ URLRequestContentJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate,
+ const base::FilePath& content_path,
+ const scoped_refptr<base::TaskRunner>& content_task_runner);
+
+ // net::URLRequestJob:
+ void Start() override;
+ void Kill() override;
+ bool ReadRawData(net::IOBuffer* buf, int buf_size, int* bytes_read) override;
+ bool IsRedirectResponse(GURL* location, int* http_status_code) override;
+ bool GetMimeType(std::string* mime_type) const override;
+ void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override;
+
+ protected:
+ ~URLRequestContentJob() override;
+
+ private:
+ // Meta information about the content URI. It's used as a member in the
+ // URLRequestContentJob and also passed between threads because disk access is
+ // necessary to obtain it.
+ struct ContentMetaInfo {
+ ContentMetaInfo();
+ // Flag showing whether the content URI exists.
+ bool content_exists;
+ // Size of the content URI.
+ int64 content_size;
+ // Mime type associated with the content URI.
+ std::string mime_type;
+ };
+
+ // Fetches content URI info on a background thread.
+ static void FetchMetaInfo(const base::FilePath& content_path,
+ ContentMetaInfo* meta_info);
+
+ // Callback after fetching content URI info on a background thread.
+ void DidFetchMetaInfo(const ContentMetaInfo* meta_info);
+
+ // Callback after opening content URI on a background thread.
+ void DidOpen(int result);
+
+ // Callback after seeking to the beginning of |byte_range_| in the content URI
+ // on a background thread.
+ void DidSeek(int64 result);
+
+ // Callback after data is asynchronously read from the content URI into |buf|.
+ void DidRead(scoped_refptr<net::IOBuffer> buf, int result);
+
+ // The full path of the content URI.
+ base::FilePath content_path_;
+
+ scoped_ptr<net::FileStream> stream_;
+ ContentMetaInfo meta_info_;
+ const scoped_refptr<base::TaskRunner> content_task_runner_;
+
+ net::HttpByteRange byte_range_;
+ int64 remaining_bytes_;
+
+ base::WeakPtrFactory<URLRequestContentJob> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(URLRequestContentJob);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_ANDROID_URL_REQUEST_CONTENT_JOB_H_

Powered by Google App Engine
This is Rietveld 408576698