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

Side by Side Diff: mojo/services/network/http_connection_impl.h

Issue 1128863004: Mojo service implementation for HTTP server - part 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ 5 #ifndef MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_
6 #define MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ 6 #define MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_
7 7
8 #include <set>
8 #include <string> 9 #include <string>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
11 #include "mojo/services/network/public/interfaces/http_connection.mojom.h" 13 #include "mojo/services/network/public/interfaces/http_connection.mojom.h"
14 #include "mojo/services/network/public/interfaces/url_loader.mojom.h"
12 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h" 15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
13 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h" 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/error_handler.h"
14 17
15 namespace net { 18 namespace net {
16 class HttpServerRequestInfo; 19 class HttpServerRequestInfo;
17 } 20 }
18 21
19 namespace mojo { 22 namespace mojo {
20 23
21 class HttpServerImpl; 24 class HttpServerImpl;
22 25
23 class HttpConnectionImpl : public HttpConnection, 26 class HttpConnectionImpl : public HttpConnection,
24 public ErrorHandler { 27 public ErrorHandler {
25 public: 28 public:
26 // |owner| must outlive this object. 29 // |owner| must outlive this object.
27 HttpConnectionImpl(int connection_id, 30 HttpConnectionImpl(int connection_id,
28 HttpServerImpl* owner, 31 HttpServerImpl* owner,
29 HttpConnectionDelegatePtr delegate, 32 HttpConnectionDelegatePtr delegate,
30 HttpConnectionPtr* connection); 33 HttpConnectionPtr* connection);
31 34
32 ~HttpConnectionImpl() override; 35 ~HttpConnectionImpl() override;
33 36
34 void OnReceivedHttpRequest(const net::HttpServerRequestInfo& info); 37 void OnReceivedHttpRequest(const net::HttpServerRequestInfo& info);
35 void OnReceivedWebSocketRequest(const net::HttpServerRequestInfo& info); 38 void OnReceivedWebSocketRequest(const net::HttpServerRequestInfo& info);
36 void OnReceivedWebSocketMessage(const std::string& data); 39 void OnReceivedWebSocketMessage(const std::string& data);
37 40
38 private: 41 private:
42 class SimpleDataPipeReader;
43
39 // HttpConnection implementation. 44 // HttpConnection implementation.
40 void SetSendBufferSize(uint32_t size, 45 void SetSendBufferSize(uint32_t size,
41 const SetSendBufferSizeCallback& callback) override; 46 const SetSendBufferSizeCallback& callback) override;
42 void SetReceiveBufferSize( 47 void SetReceiveBufferSize(
43 uint32_t size, 48 uint32_t size,
44 const SetReceiveBufferSizeCallback& callback) override; 49 const SetReceiveBufferSizeCallback& callback) override;
45 50
46 // ErrorHandler implementation. 51 // ErrorHandler implementation.
47 void OnConnectionError() override; 52 void OnConnectionError() override;
48 53
54 void OnFinishedReadingResponseBody(URLResponsePtr response_ptr,
55 SimpleDataPipeReader* reader,
56 scoped_ptr<std::string> body);
57
49 const int connection_id_; 58 const int connection_id_;
50 HttpServerImpl* const owner_; 59 HttpServerImpl* const owner_;
51 HttpConnectionDelegatePtr delegate_; 60 HttpConnectionDelegatePtr delegate_;
52 Binding<HttpConnection> binding_; 61 Binding<HttpConnection> binding_;
62 // Owns its elements.
63 std::set<SimpleDataPipeReader*> response_body_readers_;
64 bool encountered_connection_error_;
53 65
54 DISALLOW_COPY_AND_ASSIGN(HttpConnectionImpl); 66 DISALLOW_COPY_AND_ASSIGN(HttpConnectionImpl);
55 }; 67 };
56 68
57 } // namespace mojo 69 } // namespace mojo
58 70
59 #endif // MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_ 71 #endif // MOJO_SERVICES_NETWORK_HTTP_CONNECTION_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698