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

Side by Side Diff: components/arc/arc_bridge_bootstrap.cc

Issue 1684063002: Add ArcEnabled policy implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@26869593
Patch Set: Added browser test. Created 4 years, 9 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 #include "components/arc/arc_bridge_bootstrap.h" 5 #include "components/arc/arc_bridge_bootstrap.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <grp.h> 8 #include <grp.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 16 matching lines...) Expand all
27 #include "mojo/edk/embedder/platform_channel_pair.h" 27 #include "mojo/edk/embedder/platform_channel_pair.h"
28 #include "mojo/edk/embedder/platform_channel_utils_posix.h" 28 #include "mojo/edk/embedder/platform_channel_utils_posix.h"
29 #include "mojo/edk/embedder/platform_handle_vector.h" 29 #include "mojo/edk/embedder/platform_handle_vector.h"
30 #include "mojo/edk/embedder/scoped_platform_handle.h" 30 #include "mojo/edk/embedder/scoped_platform_handle.h"
31 #include "mojo/public/cpp/bindings/binding.h" 31 #include "mojo/public/cpp/bindings/binding.h"
32 32
33 namespace arc { 33 namespace arc {
34 34
35 namespace { 35 namespace {
36 36
37 scoped_ptr<ArcBridgeBootstrap> fake_bootstrap_;
bartfab (slow) 2016/03/02 14:45:40 1) Nit: It may not be a fake - it could be a mock.
Polina Bondarenko 2016/03/06 20:22:33 Done, fixed to pointer.
38
37 // We do not know the PID of ARC, since Chrome does not create it directly. 39 // We do not know the PID of ARC, since Chrome does not create it directly.
38 // Since Mojo in POSIX does not use the child PID except as an unique 40 // Since Mojo in POSIX does not use the child PID except as an unique
39 // identifier for the routing table, rather than doing a lot of plumbing in the 41 // identifier for the routing table, rather than doing a lot of plumbing in the
40 // whole system to get the correct PID, just use an arbitrary number that will 42 // whole system to get the correct PID, just use an arbitrary number that will
41 // never be used by a legitimate process. Chrome OS assigns unassigned PIDs 43 // never be used by a legitimate process. Chrome OS assigns unassigned PIDs
42 // sequentially until it reaches a certain maximum value (Chrome OS uses the 44 // sequentially until it reaches a certain maximum value (Chrome OS uses the
43 // default value of 32k), at which point it loops around to zero. An arbitrary 45 // default value of 32k), at which point it loops around to zero. An arbitrary
44 // number larger than the maximum should be safe. 46 // number larger than the maximum should be safe.
45 const pid_t kArcPid = 0x3DE0EA7C; 47 const pid_t kArcPid = 0x3DE0EA7C;
46 48
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 void ArcBridgeBootstrapImpl::SetState(State state) { 336 void ArcBridgeBootstrapImpl::SetState(State state) {
335 DCHECK(thread_checker_.CalledOnValidThread()); 337 DCHECK(thread_checker_.CalledOnValidThread());
336 // DCHECK on enum classes not supported. 338 // DCHECK on enum classes not supported.
337 DCHECK(state_ != state); 339 DCHECK(state_ != state);
338 state_ = state; 340 state_ = state;
339 } 341 }
340 342
341 } // namespace 343 } // namespace
342 344
343 ArcBridgeBootstrap::ArcBridgeBootstrap() {} 345 ArcBridgeBootstrap::ArcBridgeBootstrap() {}
344 ArcBridgeBootstrap::~ArcBridgeBootstrap() {} 346 ArcBridgeBootstrap::~ArcBridgeBootstrap() {
bartfab (slow) 2016/03/02 14:45:40 Nit: Add a blank line above.
Polina Bondarenko 2016/03/06 20:22:33 Done.
347 fake_bootstrap_.reset();
bartfab (slow) 2016/03/02 14:45:40 This should not be necessary. The global fake_boot
348 }
345 349
346 // static 350 // static
347 scoped_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() { 351 scoped_ptr<ArcBridgeBootstrap> ArcBridgeBootstrap::Create() {
348 return make_scoped_ptr(new ArcBridgeBootstrapImpl()); 352 if (fake_bootstrap_ != NULL) {
bartfab (slow) 2016/03/02 14:45:40 Nit: s/NULL/nullptr/ or, even easier, "if (fake_bo
Polina Bondarenko 2016/03/06 20:22:33 Done.
353 return make_scoped_ptr(fake_bootstrap_.release());
354 } else {
355 return make_scoped_ptr(new ArcBridgeBootstrapImpl());
356 }
357 }
358
359 // static
360 void ArcBridgeBootstrap::SetBootstrapForTesting(ArcBridgeBootstrap* bootstrap) {
361 fake_bootstrap_.reset(bootstrap);
349 } 362 }
350 363
351 } // namespace arc 364 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698