Vitaly Buka | 4615e0d | 2015-10-14 15:35:12 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Weave Authors. All rights reserved. |
Johan Euphrosine | 0ef2cd0 | 2015-10-02 15:24:50 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 5 | #ifndef LIBWEAVE_EXAMPLES_PROVIDER_EVENT_HTTP_CLIENT_H_ |
| 6 | #define LIBWEAVE_EXAMPLES_PROVIDER_EVENT_HTTP_CLIENT_H_ |
Johan Euphrosine | 0ef2cd0 | 2015-10-02 15:24:50 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/memory/weak_ptr.h> |
| 11 | #include <weave/provider/http_client.h> |
| 12 | |
ilewis | f1fa93d | 2015-11-09 09:01:11 -0800 | [diff] [blame] | 13 | #include "examples/provider/event_task_runner.h" |
| 14 | |
Johan Euphrosine | 0ef2cd0 | 2015-10-02 15:24:50 -0700 | [diff] [blame] | 15 | namespace weave { |
| 16 | namespace examples { |
| 17 | |
Johan Euphrosine | 0ef2cd0 | 2015-10-02 15:24:50 -0700 | [diff] [blame] | 18 | // Basic implementation of weave::HttpClient using libevent. |
| 19 | class EventHttpClient : public provider::HttpClient { |
| 20 | public: |
| 21 | explicit EventHttpClient(EventTaskRunner* task_runner); |
| 22 | |
Vitaly Buka | 1a42e14 | 2015-10-10 18:15:15 -0700 | [diff] [blame] | 23 | void SendRequest(Method method, |
Vitaly Buka | 866b60a | 2015-10-09 14:24:55 -0700 | [diff] [blame] | 24 | const std::string& url, |
| 25 | const Headers& headers, |
| 26 | const std::string& data, |
Vitaly Buka | 7476342 | 2015-10-11 00:39:52 -0700 | [diff] [blame] | 27 | const SendRequestCallback& callback) override; |
Johan Euphrosine | 0ef2cd0 | 2015-10-02 15:24:50 -0700 | [diff] [blame] | 28 | |
| 29 | private: |
| 30 | EventTaskRunner* task_runner_{nullptr}; |
Johan Euphrosine | 0ef2cd0 | 2015-10-02 15:24:50 -0700 | [diff] [blame] | 31 | |
| 32 | base::WeakPtrFactory<EventHttpClient> weak_ptr_factory_{this}; |
| 33 | }; |
| 34 | |
| 35 | } // namespace examples |
| 36 | } // namespace weave |
| 37 | |
Johan Euphrosine | 3523fdd | 2015-10-14 20:46:05 -0700 | [diff] [blame] | 38 | #endif // LIBWEAVE_EXAMPLES_PROVIDER_EVENT_HTTP_CLIENT_H_ |