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

Side by Side Diff: mojo/public/cpp/bindings/lib/multiplex_router.h

Issue 2611843004: Implement throttling behavior for LocalStorage mojo messages.
Patch Set: Created 3 years, 11 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_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque> 10 #include <deque>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // interfaces. In that case, this router may still receive pipe control 63 // interfaces. In that case, this router may still receive pipe control
64 // messages or messages targetting associated interfaces. 64 // messages or messages targetting associated interfaces.
65 SINGLE_INTERFACE, 65 SINGLE_INTERFACE,
66 // Similar to the mode above, there is only the master interface running on 66 // Similar to the mode above, there is only the master interface running on
67 // this router. Besides, the master interface has sync methods. 67 // this router. Besides, the master interface has sync methods.
68 SINGLE_INTERFACE_WITH_SYNC_METHODS, 68 SINGLE_INTERFACE_WITH_SYNC_METHODS,
69 // There may be associated interfaces running on this router. 69 // There may be associated interfaces running on this router.
70 MULTI_INTERFACE 70 MULTI_INTERFACE
71 }; 71 };
72 72
73 // Specifies whether we are allowed to directly call into
74 // InterfaceEndpointClient (given that we are already on the same thread as
75 // the client).
76 enum ClientCallBehavior {
77 // Don't call any InterfaceEndpointClient methods directly.
78 NO_DIRECT_CLIENT_CALLS,
79 // Only call InterfaceEndpointClient::HandleIncomingMessage directly to
80 // handle sync messages.
81 ALLOW_DIRECT_CLIENT_CALLS_FOR_SYNC_MESSAGES,
82 // Allow to call any InterfaceEndpointClient methods directly.
83 ALLOW_DIRECT_CLIENT_CALLS
84 };
85
73 // If |set_interface_id_namespace_bit| is true, the interface IDs generated by 86 // If |set_interface_id_namespace_bit| is true, the interface IDs generated by
74 // this router will have the highest bit set. 87 // this router will have the highest bit set.
75 MultiplexRouter(ScopedMessagePipeHandle message_pipe, 88 MultiplexRouter(ScopedMessagePipeHandle message_pipe,
76 Config config, 89 Config config,
77 bool set_interface_id_namespace_bit, 90 bool set_interface_id_namespace_bit,
78 scoped_refptr<base::SingleThreadTaskRunner> runner); 91 scoped_refptr<base::SingleThreadTaskRunner> runner,
92 ClientCallBehavior sync_client_call_behavior =
93 ALLOW_DIRECT_CLIENT_CALLS_FOR_SYNC_MESSAGES);
79 94
80 // Sets the master interface name for this router. Only used when reporting 95 // Sets the master interface name for this router. Only used when reporting
81 // message header or control message validation errors. 96 // message header or control message validation errors.
82 void SetMasterInterfaceName(const std::string& name); 97 void SetMasterInterfaceName(const std::string& name);
83 98
84 // --------------------------------------------------------------------------- 99 // ---------------------------------------------------------------------------
85 // The following public methods are safe to call from any threads. 100 // The following public methods are safe to call from any threads.
86 101
87 // AssociatedGroupController implementation: 102 // AssociatedGroupController implementation:
88 void CreateEndpointHandlePair( 103 void CreateEndpointHandlePair(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 171
157 // MessageReceiver implementation: 172 // MessageReceiver implementation:
158 bool Accept(Message* message) override; 173 bool Accept(Message* message) override;
159 174
160 // PipeControlMessageHandlerDelegate implementation: 175 // PipeControlMessageHandlerDelegate implementation:
161 bool OnPeerAssociatedEndpointClosed(InterfaceId id) override; 176 bool OnPeerAssociatedEndpointClosed(InterfaceId id) override;
162 bool OnAssociatedEndpointClosedBeforeSent(InterfaceId id) override; 177 bool OnAssociatedEndpointClosedBeforeSent(InterfaceId id) override;
163 178
164 void OnPipeConnectionError(); 179 void OnPipeConnectionError();
165 180
166 // Specifies whether we are allowed to directly call into
167 // InterfaceEndpointClient (given that we are already on the same thread as
168 // the client).
169 enum ClientCallBehavior {
170 // Don't call any InterfaceEndpointClient methods directly.
171 NO_DIRECT_CLIENT_CALLS,
172 // Only call InterfaceEndpointClient::HandleIncomingMessage directly to
173 // handle sync messages.
174 ALLOW_DIRECT_CLIENT_CALLS_FOR_SYNC_MESSAGES,
175 // Allow to call any InterfaceEndpointClient methods directly.
176 ALLOW_DIRECT_CLIENT_CALLS
177 };
178
179 // Processes enqueued tasks (incoming messages and error notifications). 181 // Processes enqueued tasks (incoming messages and error notifications).
180 // |current_task_runner| is only used when |client_call_behavior| is 182 // |current_task_runner| is only used when |client_call_behavior| is
181 // ALLOW_DIRECT_CLIENT_CALLS to determine whether we are on the right task 183 // ALLOW_DIRECT_CLIENT_CALLS to determine whether we are on the right task
182 // runner to make client calls for async messages or connection error 184 // runner to make client calls for async messages or connection error
183 // notifications. 185 // notifications.
184 // 186 //
185 // Note: Because calling into InterfaceEndpointClient may lead to destruction 187 // Note: Because calling into InterfaceEndpointClient may lead to destruction
186 // of this object, if direct calls are allowed, the caller needs to hold on to 188 // of this object, if direct calls are allowed, the caller needs to hold on to
187 // a ref outside of |lock_| before calling this method. 189 // a ref outside of |lock_| before calling this method.
188 void ProcessTasks(ClientCallBehavior client_call_behavior, 190 void ProcessTasks(ClientCallBehavior client_call_behavior,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 255
254 bool posted_to_process_tasks_; 256 bool posted_to_process_tasks_;
255 scoped_refptr<base::SingleThreadTaskRunner> posted_to_task_runner_; 257 scoped_refptr<base::SingleThreadTaskRunner> posted_to_task_runner_;
256 258
257 bool encountered_error_; 259 bool encountered_error_;
258 260
259 bool paused_; 261 bool paused_;
260 262
261 bool testing_mode_; 263 bool testing_mode_;
262 264
265 ClientCallBehavior sync_client_call_behavior_;
266
263 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter); 267 DISALLOW_COPY_AND_ASSIGN(MultiplexRouter);
264 }; 268 };
265 269
266 } // namespace internal 270 } // namespace internal
267 } // namespace mojo 271 } // namespace mojo
268 272
269 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_ 273 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_MULTIPLEX_ROUTER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_ptr_state.h ('k') | mojo/public/cpp/bindings/lib/multiplex_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698