OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "blimp/common/create_blimp_message.h" | |
6 | |
7 #include <memory> | |
8 | |
9 #include "base/logging.h" | |
10 #include "blimp/common/proto/blimp_message.pb.h" | |
11 #include "blimp/common/proto/blob_channel.pb.h" | |
12 #include "blimp/common/proto/compositor.pb.h" | |
13 #include "blimp/common/proto/geolocation.pb.h" | |
14 #include "blimp/common/proto/input.pb.h" | |
15 #include "blimp/common/proto/render_widget.pb.h" | |
16 #include "blimp/common/proto/settings.pb.h" | |
17 #include "blimp/common/proto/tab_control.pb.h" | |
18 | |
19 namespace blimp { | |
20 | |
21 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
22 CompositorMessage** compositor_message, | |
23 int target_tab_id) { | |
24 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
25 output->set_target_tab_id(target_tab_id); | |
26 *compositor_message = output->mutable_compositor(); | |
27 return output; | |
28 } | |
29 | |
30 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
31 TabControlMessage** control_message) { | |
32 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
33 *control_message = output->mutable_tab_control(); | |
34 return output; | |
35 } | |
36 | |
37 std::unique_ptr<BlimpMessage> CreateBlimpMessage(InputMessage** input_message) { | |
38 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
39 *input_message = output->mutable_input(); | |
40 return output; | |
41 } | |
42 | |
43 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
44 NavigationMessage** navigation_message, | |
45 int target_tab_id) { | |
46 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
47 output->set_target_tab_id(target_tab_id); | |
48 *navigation_message = output->mutable_navigation(); | |
49 return output; | |
50 } | |
51 | |
52 std::unique_ptr<BlimpMessage> CreateBlimpMessage(ImeMessage** ime_message, | |
53 int target_tab_id) { | |
54 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
55 output->set_target_tab_id(target_tab_id); | |
56 *ime_message = output->mutable_ime(); | |
57 return output; | |
58 } | |
59 | |
60 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
61 RenderWidgetMessage** render_widget_message, | |
62 int target_tab_id) { | |
63 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
64 output->set_target_tab_id(target_tab_id); | |
65 *render_widget_message = output->mutable_render_widget(); | |
66 return output; | |
67 } | |
68 | |
69 std::unique_ptr<BlimpMessage> CreateBlimpMessage(SizeMessage** size_message) { | |
70 TabControlMessage* control_message; | |
71 std::unique_ptr<BlimpMessage> output = CreateBlimpMessage(&control_message); | |
72 control_message->mutable_size(); | |
73 *size_message = control_message->mutable_size(); | |
74 return output; | |
75 } | |
76 | |
77 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
78 EngineSettingsMessage** engine_settings) { | |
79 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
80 *engine_settings = output->mutable_settings()->mutable_engine_settings(); | |
81 return output; | |
82 } | |
83 | |
84 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
85 BlobChannelMessage** blob_channel_message) { | |
86 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
87 *blob_channel_message = output->mutable_blob_channel(); | |
88 return output; | |
89 } | |
90 | |
91 std::unique_ptr<BlimpMessage> CreateBlimpMessage( | |
92 GeolocationMessage** geolocation_message) { | |
93 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
94 *geolocation_message = output->mutable_geolocation(); | |
95 return output; | |
96 } | |
97 | |
98 std::unique_ptr<BlimpMessage> CreateStartConnectionMessage( | |
99 const std::string& client_auth_token, | |
100 int protocol_version) { | |
101 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
102 | |
103 ProtocolControlMessage* control_message = output->mutable_protocol_control(); | |
104 control_message->mutable_start_connection(); | |
105 | |
106 StartConnectionMessage* start_connection_message = | |
107 control_message->mutable_start_connection(); | |
108 start_connection_message->set_client_auth_token(client_auth_token); | |
109 start_connection_message->set_protocol_version(protocol_version); | |
110 | |
111 return output; | |
112 } | |
113 | |
114 std::unique_ptr<BlimpMessage> CreateCheckpointAckMessage( | |
115 int64_t checkpoint_id) { | |
116 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
117 | |
118 ProtocolControlMessage* control_message = output->mutable_protocol_control(); | |
119 CheckpointAckMessage* checkpoint_ack_message = | |
120 control_message->mutable_checkpoint_ack(); | |
121 checkpoint_ack_message->set_checkpoint_id(checkpoint_id); | |
122 | |
123 return output; | |
124 } | |
125 | |
126 std::unique_ptr<BlimpMessage> CreateEndConnectionMessage( | |
127 EndConnectionMessage::Reason reason) { | |
128 std::unique_ptr<BlimpMessage> output(new BlimpMessage); | |
129 | |
130 ProtocolControlMessage* control_message = output->mutable_protocol_control(); | |
131 EndConnectionMessage* end_connection_message = | |
132 control_message->mutable_end_connection(); | |
133 end_connection_message->set_reason(reason); | |
134 | |
135 return output; | |
136 } | |
137 | |
138 } // namespace blimp | |
OLD | NEW |