OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_ |
| 6 #define REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "ppapi/cpp/instance_handle.h" |
| 10 #include "ppapi/cpp/url_loader.h" |
| 11 #include "ppapi/cpp/url_request_info.h" |
| 12 #include "ppapi/utility/completion_callback_factory.h" |
| 13 #include "remoting/base/url_request.h" |
| 14 |
| 15 namespace remoting { |
| 16 |
| 17 // UrlRequest implementation that uses URLLoader provided by Pepper. |
| 18 class PepperUrlRequest : public UrlRequest { |
| 19 public: |
| 20 PepperUrlRequest(pp::InstanceHandle pp_instance, const std::string& url); |
| 21 ~PepperUrlRequest() override; |
| 22 |
| 23 // UrlRequest interface. |
| 24 void AddHeader(const std::string& value) override; |
| 25 void Start(const OnResultCallback& on_result_callback) override; |
| 26 |
| 27 private: |
| 28 void OnUrlOpened(int32_t result); |
| 29 void ReadResponseBody(); |
| 30 void OnResponseBodyRead(int32_t result); |
| 31 |
| 32 pp::URLRequestInfo request_info_; |
| 33 pp::URLLoader url_loader_; |
| 34 std::string url_; |
| 35 |
| 36 std::string headers_; |
| 37 |
| 38 OnResultCallback on_result_callback_; |
| 39 |
| 40 std::string response_; |
| 41 |
| 42 pp::CompletionCallbackFactory<PepperUrlRequest> callback_factory_; |
| 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(PepperUrlRequest); |
| 45 }; |
| 46 |
| 47 class PepperUrlRequestFactory : public UrlRequestFactory { |
| 48 public: |
| 49 PepperUrlRequestFactory(pp::InstanceHandle pp_instance); |
| 50 ~PepperUrlRequestFactory() override; |
| 51 |
| 52 // UrlRequestFactory interface. |
| 53 scoped_ptr<UrlRequest> CreateUrlRequest(const std::string& url) override; |
| 54 |
| 55 private: |
| 56 pp::InstanceHandle pp_instance_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(PepperUrlRequestFactory); |
| 59 }; |
| 60 |
| 61 } // namespace remoting |
| 62 |
| 63 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_ |
OLD | NEW |