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

Unified Diff: remoting/client/plugin/pepper_url_request.h

Issue 1679023009: Add remoting::UrlRequest interface with 2 implementations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/base/url_request.h ('k') | remoting/client/plugin/pepper_url_request.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/client/plugin/pepper_url_request.h
diff --git a/remoting/client/plugin/pepper_url_request.h b/remoting/client/plugin/pepper_url_request.h
new file mode 100644
index 0000000000000000000000000000000000000000..5bacef9d39369e371f2b5f4e61590d3155f5d2d8
--- /dev/null
+++ b/remoting/client/plugin/pepper_url_request.h
@@ -0,0 +1,63 @@
+// Copyright 2016 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 REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_
+#define REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_
+
+#include "base/callback.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/url_loader.h"
+#include "ppapi/cpp/url_request_info.h"
+#include "ppapi/utility/completion_callback_factory.h"
+#include "remoting/base/url_request.h"
+
+namespace remoting {
+
+// UrlRequest implementation that uses URLLoader provided by Pepper.
+class PepperUrlRequest : public UrlRequest {
+ public:
+ PepperUrlRequest(pp::InstanceHandle pp_instance, const std::string& url);
+ ~PepperUrlRequest() override;
+
+ // UrlRequest interface.
+ void AddHeader(const std::string& value) override;
+ void Start(const OnResultCallback& on_result_callback) override;
+
+ private:
+ void OnUrlOpened(int32_t result);
+ void ReadResponseBody();
+ void OnResponseBodyRead(int32_t result);
+
+ pp::URLRequestInfo request_info_;
+ pp::URLLoader url_loader_;
+ std::string url_;
+
+ std::string headers_;
+
+ OnResultCallback on_result_callback_;
+
+ std::string response_;
+
+ pp::CompletionCallbackFactory<PepperUrlRequest> callback_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperUrlRequest);
+};
+
+class PepperUrlRequestFactory : public UrlRequestFactory {
+ public:
+ PepperUrlRequestFactory(pp::InstanceHandle pp_instance);
+ ~PepperUrlRequestFactory() override;
+
+ // UrlRequestFactory interface.
+ scoped_ptr<UrlRequest> CreateUrlRequest(const std::string& url) override;
+
+ private:
+ pp::InstanceHandle pp_instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperUrlRequestFactory);
+};
+
+} // namespace remoting
+
+#endif // REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_
« no previous file with comments | « remoting/base/url_request.h ('k') | remoting/client/plugin/pepper_url_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698