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

Side by Side Diff: mojo/public/cpp/bindings/lib/router.cc

Issue 2084993002: Mojo: add support for disallowing sync calls for a process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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
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 "mojo/public/cpp/bindings/lib/router.h" 5 #include "mojo/public/cpp/bindings/lib/router.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "mojo/public/cpp/bindings/sync_call_restrictions.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 namespace internal { 19 namespace internal {
19 20
20 // ---------------------------------------------------------------------------- 21 // ----------------------------------------------------------------------------
21 22
22 namespace { 23 namespace {
23 24
24 void DCheckIfInvalid(const base::WeakPtr<Router>& router, 25 void DCheckIfInvalid(const base::WeakPtr<Router>& router,
25 const std::string& message) { 26 const std::string& message) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 message->set_request_id(request_id); 159 message->set_request_id(request_id);
159 if (!connector_.Accept(message)) 160 if (!connector_.Accept(message))
160 return false; 161 return false;
161 162
162 if (!is_sync) { 163 if (!is_sync) {
163 // We assume ownership of |responder|. 164 // We assume ownership of |responder|.
164 async_responders_[request_id] = base::WrapUnique(responder); 165 async_responders_[request_id] = base::WrapUnique(responder);
165 return true; 166 return true;
166 } 167 }
167 168
169 SyncCallRestrictions::AssertSyncCallAllowed();
170
168 bool response_received = false; 171 bool response_received = false;
169 std::unique_ptr<MessageReceiver> sync_responder(responder); 172 std::unique_ptr<MessageReceiver> sync_responder(responder);
170 sync_responses_.insert(std::make_pair( 173 sync_responses_.insert(std::make_pair(
171 request_id, base::WrapUnique(new SyncResponseInfo(&response_received)))); 174 request_id, base::WrapUnique(new SyncResponseInfo(&response_received))));
172 175
173 base::WeakPtr<Router> weak_self = weak_factory_.GetWeakPtr(); 176 base::WeakPtr<Router> weak_self = weak_factory_.GetWeakPtr();
174 connector_.SyncWatch(&response_received); 177 connector_.SyncWatch(&response_received);
175 // Make sure that this instance hasn't been destroyed. 178 // Make sure that this instance hasn't been destroyed.
176 if (weak_self) { 179 if (weak_self) {
177 DCHECK(ContainsKey(sync_responses_, request_id)); 180 DCHECK(ContainsKey(sync_responses_, request_id));
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 314
312 encountered_error_ = true; 315 encountered_error_ = true;
313 if (!error_handler_.is_null()) 316 if (!error_handler_.is_null())
314 error_handler_.Run(); 317 error_handler_.Run();
315 } 318 }
316 319
317 // ---------------------------------------------------------------------------- 320 // ----------------------------------------------------------------------------
318 321
319 } // namespace internal 322 } // namespace internal
320 } // namespace mojo 323 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/interface_endpoint_client.cc ('k') | mojo/public/cpp/bindings/lib/sync_call_restrictions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698