OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 {{"_".join(config.protocol.namespace)}}_DispatcherBase_h | 5 #ifndef {{"_".join(config.protocol.namespace)}}_DispatcherBase_h |
6 #define {{"_".join(config.protocol.namespace)}}_DispatcherBase_h | 6 #define {{"_".join(config.protocol.namespace)}}_DispatcherBase_h |
7 | 7 |
8 //#include "BackendCallback.h" | 8 //#include "BackendCallback.h" |
9 //#include "Collections.h" | 9 //#include "Collections.h" |
10 //#include "ErrorSupport.h" | 10 //#include "ErrorSupport.h" |
11 //#include "Forward.h" | 11 //#include "Forward.h" |
12 //#include "Values.h" | 12 //#include "Values.h" |
13 | 13 |
14 {% for namespace in config.protocol.namespace %} | 14 {% for namespace in config.protocol.namespace %} |
15 namespace {{namespace}} { | 15 namespace {{namespace}} { |
16 {% endfor %} | 16 {% endfor %} |
17 | 17 |
18 class WeakPtr; | 18 class WeakPtr; |
19 | 19 |
20 class {{config.class_export.macro}} DispatcherBase { | 20 class {{config.lib.export_macro}} DispatcherBase { |
21 PROTOCOL_DISALLOW_COPY(DispatcherBase); | 21 PROTOCOL_DISALLOW_COPY(DispatcherBase); |
22 public: | 22 public: |
23 static const char kInvalidRequest[]; | 23 static const char kInvalidRequest[]; |
24 class {{config.class_export.macro}} WeakPtr { | 24 class {{config.lib.export_macro}} WeakPtr { |
25 public: | 25 public: |
26 explicit WeakPtr(DispatcherBase*); | 26 explicit WeakPtr(DispatcherBase*); |
27 ~WeakPtr(); | 27 ~WeakPtr(); |
28 DispatcherBase* get() { return m_dispatcher; } | 28 DispatcherBase* get() { return m_dispatcher; } |
29 void dispose() { m_dispatcher = nullptr; } | 29 void dispose() { m_dispatcher = nullptr; } |
30 | 30 |
31 private: | 31 private: |
32 DispatcherBase* m_dispatcher; | 32 DispatcherBase* m_dispatcher; |
33 }; | 33 }; |
34 | 34 |
35 class {{config.class_export.macro}} Callback : public protocol::BackendCallb
ack { | 35 class {{config.lib.export_macro}} Callback : public protocol::BackendCallbac
k { |
36 public: | 36 public: |
37 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId); | 37 Callback(std::unique_ptr<WeakPtr> backendImpl, int callId); |
38 virtual ~Callback(); | 38 virtual ~Callback(); |
39 void dispose(); | 39 void dispose(); |
40 | 40 |
41 protected: | 41 protected: |
42 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess
age, const ErrorString& invocationError); | 42 void sendIfActive(std::unique_ptr<protocol::DictionaryValue> partialMess
age, const ErrorString& invocationError); |
43 | 43 |
44 private: | 44 private: |
45 std::unique_ptr<WeakPtr> m_backendImpl; | 45 std::unique_ptr<WeakPtr> m_backendImpl; |
(...skipping 23 matching lines...) Expand all Loading... |
69 void reportProtocolError(int callId, CommonErrorCode, const String& errorMes
sage, ErrorSupport* errors); | 69 void reportProtocolError(int callId, CommonErrorCode, const String& errorMes
sage, ErrorSupport* errors); |
70 void clearFrontend(); | 70 void clearFrontend(); |
71 | 71 |
72 std::unique_ptr<WeakPtr> weakPtr(); | 72 std::unique_ptr<WeakPtr> weakPtr(); |
73 | 73 |
74 private: | 74 private: |
75 FrontendChannel* m_frontendChannel; | 75 FrontendChannel* m_frontendChannel; |
76 protocol::HashSet<WeakPtr*> m_weakPtrs; | 76 protocol::HashSet<WeakPtr*> m_weakPtrs; |
77 }; | 77 }; |
78 | 78 |
79 class {{config.class_export.macro}} UberDispatcher { | 79 class {{config.lib.export_macro}} UberDispatcher { |
80 PROTOCOL_DISALLOW_COPY(UberDispatcher); | 80 PROTOCOL_DISALLOW_COPY(UberDispatcher); |
81 public: | 81 public: |
82 explicit UberDispatcher(FrontendChannel*); | 82 explicit UberDispatcher(FrontendChannel*); |
83 void registerBackend(const String& name, std::unique_ptr<protocol::Dispatche
rBase>); | 83 void registerBackend(const String& name, std::unique_ptr<protocol::Dispatche
rBase>); |
84 void dispatch(std::unique_ptr<Value> message); | 84 void dispatch(std::unique_ptr<Value> message); |
85 FrontendChannel* channel() { return m_frontendChannel; } | 85 FrontendChannel* channel() { return m_frontendChannel; } |
86 virtual ~UberDispatcher(); | 86 virtual ~UberDispatcher(); |
87 | 87 |
88 private: | 88 private: |
89 FrontendChannel* m_frontendChannel; | 89 FrontendChannel* m_frontendChannel; |
90 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa
tchers; | 90 protocol::HashMap<String, std::unique_ptr<protocol::DispatcherBase>> m_dispa
tchers; |
91 }; | 91 }; |
92 | 92 |
93 {% for namespace in config.protocol.namespace %} | 93 {% for namespace in config.protocol.namespace %} |
94 } // namespace {{namespace}} | 94 } // namespace {{namespace}} |
95 {% endfor %} | 95 {% endfor %} |
96 | 96 |
97 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h) | 97 #endif // !defined({{"_".join(config.protocol.namespace)}}_DispatcherBase_h) |
OLD | NEW |