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

Side by Side Diff: ipc/mojo/ipc_mojo_bootstrap.cc

Issue 2080513002: Deletes mojo::Callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
« no previous file with comments | « extensions/browser/mojo/stash_backend.cc ('k') | media/capture/video/scoped_result_callback.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ipc/mojo/ipc_mojo_bootstrap.h" 5 #include "ipc/mojo/ipc_mojo_bootstrap.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h"
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
13 #include "base/process/process_handle.h" 14 #include "base/process/process_handle.h"
14 #include "build/build_config.h" 15 #include "build/build_config.h"
15 #include "ipc/ipc_message_utils.h" 16 #include "ipc/ipc_message_utils.h"
16 #include "ipc/ipc_platform_file.h" 17 #include "ipc/ipc_platform_file.h"
17 #include "mojo/public/cpp/bindings/binding.h" 18 #include "mojo/public/cpp/bindings/binding.h"
18 19
19 namespace IPC { 20 namespace IPC {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 68 }
68 69
69 void MojoServerBootstrap::OnInitDone(int32_t peer_pid) { 70 void MojoServerBootstrap::OnInitDone(int32_t peer_pid) {
70 if (state() != STATE_WAITING_ACK) { 71 if (state() != STATE_WAITING_ACK) {
71 set_state(STATE_ERROR); 72 set_state(STATE_ERROR);
72 LOG(ERROR) << "Got inconsistent message from client."; 73 LOG(ERROR) << "Got inconsistent message from client.";
73 return; 74 return;
74 } 75 }
75 76
76 set_state(STATE_READY); 77 set_state(STATE_READY);
77 bootstrap_.set_connection_error_handler(mojo::Closure()); 78 bootstrap_.set_connection_error_handler(base::Closure());
78 delegate()->OnPipesAvailable(std::move(send_channel_), 79 delegate()->OnPipesAvailable(std::move(send_channel_),
79 std::move(receive_channel_request_), peer_pid); 80 std::move(receive_channel_request_), peer_pid);
80 } 81 }
81 82
82 // MojoBootstrap for client processes. You should create the instance 83 // MojoBootstrap for client processes. You should create the instance
83 // using MojoBootstrap::Create(). 84 // using MojoBootstrap::Create().
84 class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap { 85 class MojoClientBootstrap : public MojoBootstrap, public mojom::Bootstrap {
85 public: 86 public:
86 MojoClientBootstrap(); 87 MojoClientBootstrap();
87 88
88 private: 89 private:
89 // MojoBootstrap implementation. 90 // MojoBootstrap implementation.
90 void Connect() override; 91 void Connect() override;
91 92
92 // mojom::Bootstrap implementation. 93 // mojom::Bootstrap implementation.
93 void Init(mojom::ChannelAssociatedRequest receive_channel, 94 void Init(mojom::ChannelAssociatedRequest receive_channel,
94 mojom::ChannelAssociatedPtrInfo send_channel, 95 mojom::ChannelAssociatedPtrInfo send_channel,
95 int32_t peer_pid, 96 int32_t peer_pid,
96 const mojo::Callback<void(int32_t)>& callback) override; 97 const InitCallback& callback) override;
97 98
98 mojo::Binding<mojom::Bootstrap> binding_; 99 mojo::Binding<mojom::Bootstrap> binding_;
99 100
100 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap); 101 DISALLOW_COPY_AND_ASSIGN(MojoClientBootstrap);
101 }; 102 };
102 103
103 MojoClientBootstrap::MojoClientBootstrap() : binding_(this) {} 104 MojoClientBootstrap::MojoClientBootstrap() : binding_(this) {}
104 105
105 void MojoClientBootstrap::Connect() { 106 void MojoClientBootstrap::Connect() {
106 binding_.Bind(TakeHandle()); 107 binding_.Bind(TakeHandle());
107 binding_.set_connection_error_handler( 108 binding_.set_connection_error_handler(
108 base::Bind(&MojoClientBootstrap::Fail, base::Unretained(this))); 109 base::Bind(&MojoClientBootstrap::Fail, base::Unretained(this)));
109 } 110 }
110 111
111 void MojoClientBootstrap::Init(mojom::ChannelAssociatedRequest receive_channel, 112 void MojoClientBootstrap::Init(mojom::ChannelAssociatedRequest receive_channel,
112 mojom::ChannelAssociatedPtrInfo send_channel, 113 mojom::ChannelAssociatedPtrInfo send_channel,
113 int32_t peer_pid, 114 int32_t peer_pid,
114 const mojo::Callback<void(int32_t)>& callback) { 115 const InitCallback& callback) {
115 callback.Run(GetSelfPID()); 116 callback.Run(GetSelfPID());
116 set_state(STATE_READY); 117 set_state(STATE_READY);
117 binding_.set_connection_error_handler(mojo::Closure()); 118 binding_.set_connection_error_handler(base::Closure());
118 delegate()->OnPipesAvailable(std::move(send_channel), 119 delegate()->OnPipesAvailable(std::move(send_channel),
119 std::move(receive_channel), peer_pid); 120 std::move(receive_channel), peer_pid);
120 } 121 }
121 122
122 } // namespace 123 } // namespace
123 124
124 // MojoBootstrap 125 // MojoBootstrap
125 126
126 // static 127 // static
127 std::unique_ptr<MojoBootstrap> MojoBootstrap::Create( 128 std::unique_ptr<MojoBootstrap> MojoBootstrap::Create(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 165
165 bool MojoBootstrap::HasFailed() const { 166 bool MojoBootstrap::HasFailed() const {
166 return state() == STATE_ERROR; 167 return state() == STATE_ERROR;
167 } 168 }
168 169
169 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() { 170 mojo::ScopedMessagePipeHandle MojoBootstrap::TakeHandle() {
170 return std::move(handle_); 171 return std::move(handle_);
171 } 172 }
172 173
173 } // namespace IPC 174 } // namespace IPC
OLDNEW
« no previous file with comments | « extensions/browser/mojo/stash_backend.cc ('k') | media/capture/video/scoped_result_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698