OLD | NEW |
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 BLIMP_NET_BROWSER_CONNECTION_HANDLER_H_ | 5 #ifndef BLIMP_NET_BROWSER_CONNECTION_HANDLER_H_ |
6 #define BLIMP_NET_BROWSER_CONNECTION_HANDLER_H_ | 6 #define BLIMP_NET_BROWSER_CONNECTION_HANDLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // the lifetime of the application. | 28 // the lifetime of the application. |
29 // BrowserConnectionHandler is created on the UI thread, and then used and | 29 // BrowserConnectionHandler is created on the UI thread, and then used and |
30 // destroyed on the IO thread. | 30 // destroyed on the IO thread. |
31 class BLIMP_NET_EXPORT BrowserConnectionHandler | 31 class BLIMP_NET_EXPORT BrowserConnectionHandler |
32 : public ConnectionHandler, | 32 : public ConnectionHandler, |
33 public ConnectionErrorObserver { | 33 public ConnectionErrorObserver { |
34 public: | 34 public: |
35 BrowserConnectionHandler(); | 35 BrowserConnectionHandler(); |
36 ~BrowserConnectionHandler() override; | 36 ~BrowserConnectionHandler() override; |
37 | 37 |
38 // Registers a message processor which will receive all messages of the |type| | 38 // Registers a message processor which will receive all messages of the |
39 // specified. Only one handler may be added per type. | 39 // |feature_case| specified. Only one handler may be added per feature. |
40 // That caller must ensure |incoming_processor| remains valid while | 40 // That caller must ensure |incoming_processor| remains valid while |
41 // this object is in-use. | 41 // this object is in-use. |
42 // | 42 // |
43 // Returns a BlimpMessageProcessor object for sending messages of type |type|. | 43 // Returns a BlimpMessageProcessor object for sending messages for a given |
| 44 // feature. |
44 virtual std::unique_ptr<BlimpMessageProcessor> RegisterFeature( | 45 virtual std::unique_ptr<BlimpMessageProcessor> RegisterFeature( |
45 BlimpMessage::Type type, | 46 BlimpMessage::FeatureCase feature_case, |
46 BlimpMessageProcessor* incoming_processor); | 47 BlimpMessageProcessor* incoming_processor); |
47 | 48 |
48 // ConnectionHandler implementation. | 49 // ConnectionHandler implementation. |
49 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; | 50 void HandleConnection(std::unique_ptr<BlimpConnection> connection) override; |
50 | 51 |
51 // ConnectionErrorObserver implementation. | 52 // ConnectionErrorObserver implementation. |
52 void OnConnectionError(int error) override; | 53 void OnConnectionError(int error) override; |
53 | 54 |
54 private: | 55 private: |
55 void DropCurrentConnection(); | 56 void DropCurrentConnection(); |
(...skipping 14 matching lines...) Expand all Loading... |
70 | 71 |
71 // Holds network resources while there is a Client connected. | 72 // Holds network resources while there is a Client connected. |
72 std::unique_ptr<BlimpConnection> connection_; | 73 std::unique_ptr<BlimpConnection> connection_; |
73 | 74 |
74 DISALLOW_COPY_AND_ASSIGN(BrowserConnectionHandler); | 75 DISALLOW_COPY_AND_ASSIGN(BrowserConnectionHandler); |
75 }; | 76 }; |
76 | 77 |
77 } // namespace blimp | 78 } // namespace blimp |
78 | 79 |
79 #endif // BLIMP_NET_BROWSER_CONNECTION_HANDLER_H_ | 80 #endif // BLIMP_NET_BROWSER_CONNECTION_HANDLER_H_ |
OLD | NEW |