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_BLIMP_MESSAGE_PUMP_H_ | 5 #ifndef BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ |
6 #define BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ | 6 #define BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "blimp/net/blimp_connection_details.h" |
13 #include "blimp/net/blimp_net_export.h" | 14 #include "blimp/net/blimp_net_export.h" |
| 15 #include "blimp/net/packet_reader.h" |
14 #include "net/base/completion_callback.h" | 16 #include "net/base/completion_callback.h" |
15 | 17 |
16 namespace net { | 18 namespace net { |
17 class GrowableIOBuffer; | 19 class GrowableIOBuffer; |
18 } | 20 } |
19 | 21 |
20 namespace blimp { | 22 namespace blimp { |
21 | 23 |
22 class BlimpMessageProcessor; | 24 class BlimpMessageProcessor; |
23 class ConnectionErrorObserver; | 25 class ConnectionErrorObserver; |
(...skipping 13 matching lines...) Expand all Loading... |
37 // Caller retains the ownership of |processor|. | 39 // Caller retains the ownership of |processor|. |
38 // The processor can be unset by passing a null pointer when no reads are | 40 // The processor can be unset by passing a null pointer when no reads are |
39 // inflight, ie. after |processor_|->ProcessMessage() is called, but before | 41 // inflight, ie. after |processor_|->ProcessMessage() is called, but before |
40 // ProcessMessage() invokes its completion callback. | 42 // ProcessMessage() invokes its completion callback. |
41 void SetMessageProcessor(BlimpMessageProcessor* processor); | 43 void SetMessageProcessor(BlimpMessageProcessor* processor); |
42 | 44 |
43 void set_error_observer(ConnectionErrorObserver* observer) { | 45 void set_error_observer(ConnectionErrorObserver* observer) { |
44 error_observer_ = observer; | 46 error_observer_ = observer; |
45 } | 47 } |
46 | 48 |
| 49 void SetBlimpConnectionDetails(BlimpConnectionDetails* connection_details) { |
| 50 DCHECK(reader_); |
| 51 reader_->SetBlimpConnectionDetails(connection_details); |
| 52 } |
| 53 |
47 private: | 54 private: |
48 // Read next packet from |reader_|. | 55 // Read next packet from |reader_|. |
49 void ReadNextPacket(); | 56 void ReadNextPacket(); |
50 | 57 |
51 // Callback when next packet is ready in |buffer_|. | 58 // Callback when next packet is ready in |buffer_|. |
52 void OnReadPacketComplete(int result); | 59 void OnReadPacketComplete(int result); |
53 | 60 |
54 // Callback when |processor_| finishes processing a BlimpMessage. | 61 // Callback when |processor_| finishes processing a BlimpMessage. |
55 // Any values other than net::OK indicate that |processor_| has encountered an | 62 // Any values other than net::OK indicate that |processor_| has encountered an |
56 // error that should be handled. Currently all errors will cause the | 63 // error that should be handled. Currently all errors will cause the |
(...skipping 10 matching lines...) Expand all Loading... |
67 | 74 |
68 // Used to abandon ProcessMessage completion callbacks if |this| is deleted. | 75 // Used to abandon ProcessMessage completion callbacks if |this| is deleted. |
69 base::WeakPtrFactory<BlimpMessagePump> weak_factory_; | 76 base::WeakPtrFactory<BlimpMessagePump> weak_factory_; |
70 | 77 |
71 DISALLOW_COPY_AND_ASSIGN(BlimpMessagePump); | 78 DISALLOW_COPY_AND_ASSIGN(BlimpMessagePump); |
72 }; | 79 }; |
73 | 80 |
74 } // namespace blimp | 81 } // namespace blimp |
75 | 82 |
76 #endif // BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ | 83 #endif // BLIMP_NET_BLIMP_MESSAGE_PUMP_H_ |
OLD | NEW |