Chromium Code Reviews| 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 | |
|
Jamie
2016/02/11 01:58:44
Add "// URLRequest interface."
Sergey Ulanov
2016/02/11 18:57:38
Done.
| |
| 23 void AddHeader(const std::string& value) override; | |
| 24 void Start(const OnResultCallback& on_result_callback) override; | |
| 25 | |
| 26 private: | |
| 27 void OnUrlOpened(int32_t result); | |
| 28 void ReadResponseBody(); | |
| 29 void OnResponseBodyRead(int32_t result); | |
| 30 | |
| 31 pp::URLRequestInfo request_info_; | |
| 32 pp::URLLoader url_loader_; | |
| 33 std::string url_; | |
| 34 | |
| 35 std::string headers_; | |
| 36 | |
| 37 OnResultCallback on_result_callback_; | |
| 38 | |
| 39 std::string response_; | |
| 40 | |
| 41 pp::CompletionCallbackFactory<PepperUrlRequest> callback_factory_; | |
| 42 | |
| 43 DISALLOW_COPY_AND_ASSIGN(PepperUrlRequest); | |
| 44 }; | |
| 45 | |
| 46 class PepperUrlRequestFactory : public UrlRequestFactory { | |
| 47 public: | |
| 48 PepperUrlRequestFactory(pp::InstanceHandle pp_instance); | |
| 49 ~PepperUrlRequestFactory() override; | |
| 50 | |
| 51 // UrlRequestFactory interface. | |
| 52 scoped_ptr<UrlRequest> CreateUrlRequest(const std::string& url) override; | |
| 53 | |
| 54 private: | |
| 55 pp::InstanceHandle pp_instance_; | |
| 56 | |
| 57 DISALLOW_COPY_AND_ASSIGN(PepperUrlRequestFactory); | |
| 58 }; | |
| 59 | |
| 60 } // namespace remoting | |
| 61 | |
| 62 #endif // REMOTING_CLIENT_PLUGIN_PEPPER_URL_LOADER_H_ | |
| OLD | NEW |