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

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

Issue 2100683002: Mojo C++ Bindings: Extract AssociatedGroupController from MultiplexRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops more gyp ugh Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_INTERFACE_PTR_STATE_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> // For |std::swap()|. 10 #include <algorithm> // For |std::swap()|.
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/callback_forward.h" 15 #include "base/callback_forward.h"
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 18 #include "base/memory/ptr_util.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/single_thread_task_runner.h" 20 #include "base/single_thread_task_runner.h"
21 #include "mojo/public/cpp/bindings/associated_group.h" 21 #include "mojo/public/cpp/bindings/associated_group.h"
22 #include "mojo/public/cpp/bindings/interface_endpoint_client.h"
23 #include "mojo/public/cpp/bindings/interface_id.h"
22 #include "mojo/public/cpp/bindings/interface_ptr_info.h" 24 #include "mojo/public/cpp/bindings/interface_ptr_info.h"
23 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" 25 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h"
24 #include "mojo/public/cpp/bindings/lib/filter_chain.h" 26 #include "mojo/public/cpp/bindings/lib/filter_chain.h"
25 #include "mojo/public/cpp/bindings/lib/interface_endpoint_client.h"
26 #include "mojo/public/cpp/bindings/lib/interface_id.h"
27 #include "mojo/public/cpp/bindings/lib/message_header_validator.h" 27 #include "mojo/public/cpp/bindings/lib/message_header_validator.h"
28 #include "mojo/public/cpp/bindings/lib/multiplex_router.h" 28 #include "mojo/public/cpp/bindings/lib/multiplex_router.h"
29 #include "mojo/public/cpp/bindings/lib/router.h" 29 #include "mojo/public/cpp/bindings/lib/router.h"
30 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" 30 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
31 31
32 namespace mojo { 32 namespace mojo {
33 namespace internal { 33 namespace internal {
34 34
35 template <typename Interface, bool use_multiplex_router> 35 template <typename Interface, bool use_multiplex_router>
36 class InterfacePtrState; 36 class InterfacePtrState;
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 if (!handle_.is_valid()) 323 if (!handle_.is_valid())
324 return; 324 return;
325 325
326 router_ = new MultiplexRouter(true, std::move(handle_), runner_); 326 router_ = new MultiplexRouter(true, std::move(handle_), runner_);
327 router_->SetMasterInterfaceName(Interface::Name_); 327 router_->SetMasterInterfaceName(Interface::Name_);
328 endpoint_client_.reset(new InterfaceEndpointClient( 328 endpoint_client_.reset(new InterfaceEndpointClient(
329 router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr, 329 router_->CreateLocalEndpointHandle(kMasterInterfaceId), nullptr,
330 base::WrapUnique(new typename Interface::ResponseValidator_()), false, 330 base::WrapUnique(new typename Interface::ResponseValidator_()), false,
331 std::move(runner_))); 331 std::move(runner_)));
332 proxy_.reset(new Proxy(endpoint_client_.get())); 332 proxy_.reset(new Proxy(endpoint_client_.get()));
333 proxy_->serialization_context()->router = endpoint_client_->router(); 333 proxy_->serialization_context()->group_controller =
334 endpoint_client_->group_controller();
334 } 335 }
335 336
336 void OnQueryVersion(const base::Callback<void(uint32_t)>& callback, 337 void OnQueryVersion(const base::Callback<void(uint32_t)>& callback,
337 uint32_t version) { 338 uint32_t version) {
338 version_ = version; 339 version_ = version;
339 callback.Run(version); 340 callback.Run(version);
340 } 341 }
341 342
342 scoped_refptr<MultiplexRouter> router_; 343 scoped_refptr<MultiplexRouter> router_;
343 344
344 std::unique_ptr<InterfaceEndpointClient> endpoint_client_; 345 std::unique_ptr<InterfaceEndpointClient> endpoint_client_;
345 std::unique_ptr<Proxy> proxy_; 346 std::unique_ptr<Proxy> proxy_;
346 347
347 // |router_| (as well as other members above) is not initialized until 348 // |router_| (as well as other members above) is not initialized until
348 // read/write with the message pipe handle is needed. |handle_| is valid 349 // read/write with the message pipe handle is needed. |handle_| is valid
349 // between the Bind() call and the initialization of |router_|. 350 // between the Bind() call and the initialization of |router_|.
350 ScopedMessagePipeHandle handle_; 351 ScopedMessagePipeHandle handle_;
351 scoped_refptr<base::SingleThreadTaskRunner> runner_; 352 scoped_refptr<base::SingleThreadTaskRunner> runner_;
352 353
353 uint32_t version_; 354 uint32_t version_;
354 355
355 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState); 356 DISALLOW_COPY_AND_ASSIGN(InterfacePtrState);
356 }; 357 };
357 358
358 } // namespace internal 359 } // namespace internal
359 } // namespace mojo 360 } // namespace mojo
360 361
361 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_ 362 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_INTERFACE_PTR_STATE_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_id.h ('k') | mojo/public/cpp/bindings/lib/multiplex_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698