blob: 378c4a357c88dc8a33fbea218fd8dc761df4ddf9 [file] [log] [blame]
Vitaly Buka4615e0d2015-10-14 15:35:12 -07001// Copyright 2015 The Weave Authors. All rights reserved.
Johan Euphrosine0ef2cd02015-10-02 15:24:50 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Johan Euphrosine3523fdd2015-10-14 20:46:05 -07005#ifndef LIBWEAVE_EXAMPLES_PROVIDER_EVENT_HTTP_CLIENT_H_
6#define LIBWEAVE_EXAMPLES_PROVIDER_EVENT_HTTP_CLIENT_H_
Johan Euphrosine0ef2cd02015-10-02 15:24:50 -07007
8#include <string>
9
10#include <base/memory/weak_ptr.h>
11#include <weave/provider/http_client.h>
12
ilewisf1fa93d2015-11-09 09:01:11 -080013#include "examples/provider/event_task_runner.h"
14
Johan Euphrosine0ef2cd02015-10-02 15:24:50 -070015namespace weave {
16namespace examples {
17
Johan Euphrosine0ef2cd02015-10-02 15:24:50 -070018// Basic implementation of weave::HttpClient using libevent.
19class EventHttpClient : public provider::HttpClient {
20 public:
21 explicit EventHttpClient(EventTaskRunner* task_runner);
22
Vitaly Buka1a42e142015-10-10 18:15:15 -070023 void SendRequest(Method method,
Vitaly Buka866b60a2015-10-09 14:24:55 -070024 const std::string& url,
25 const Headers& headers,
26 const std::string& data,
Vitaly Buka74763422015-10-11 00:39:52 -070027 const SendRequestCallback& callback) override;
Johan Euphrosine0ef2cd02015-10-02 15:24:50 -070028
29 private:
30 EventTaskRunner* task_runner_{nullptr};
Johan Euphrosine0ef2cd02015-10-02 15:24:50 -070031
32 base::WeakPtrFactory<EventHttpClient> weak_ptr_factory_{this};
33};
34
35} // namespace examples
36} // namespace weave
37
Johan Euphrosine3523fdd2015-10-14 20:46:05 -070038#endif // LIBWEAVE_EXAMPLES_PROVIDER_EVENT_HTTP_CLIENT_H_