| OLD | NEW |
| 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.ComponentName; | 7 import android.content.ComponentName; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.ServiceConnection; | 10 import android.content.ServiceConnection; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 assertNotNull(replyHandler.mMessage); | 380 assertNotNull(replyHandler.mMessage); |
| 381 assertEquals(ChildProcessLauncherTestHelperService.MSG_BIND_SERVICE_REPL
Y, | 381 assertEquals(ChildProcessLauncherTestHelperService.MSG_BIND_SERVICE_REPL
Y, |
| 382 replyHandler.mMessage.what); | 382 replyHandler.mMessage.what); |
| 383 assertEquals("Connection slot from helper service is not 0", 0, replyHan
dler.mMessage.arg2); | 383 assertEquals("Connection slot from helper service is not 0", 0, replyHan
dler.mMessage.arg2); |
| 384 | 384 |
| 385 final int helperConnPid = replyHandler.mMessage.arg1; | 385 final int helperConnPid = replyHandler.mMessage.arg1; |
| 386 assertTrue(helperConnPid > 0); | 386 assertTrue(helperConnPid > 0); |
| 387 | 387 |
| 388 // Launch a service from this process. Since slot 0 is already bound by
the Helper, it | 388 // Launch a service from this process. Since slot 0 is already bound by
the Helper, it |
| 389 // will fail to start and the ChildProcessLauncher will retry. | 389 // will fail to start and the ChildProcessLauncher will retry. |
| 390 final ChildProcessConnection conn = ChildProcessLauncher.startForTesting
(context, | 390 final ChildProcessCreationParams creationParams = new ChildProcessCreati
onParams( |
| 391 sProcessWaitArguments, new FileDescriptorInfo[0], | 391 context.getPackageName(), false /* isExternalService */, |
| 392 getDefaultChildProcessCreationParams(context.getPackageName())); | 392 LibraryProcessType.PROCESS_CHILD, true /* bindToCallerCheck */); |
| 393 final ChildProcessConnection conn = ChildProcessLauncher.startForTesting
( |
| 394 context, sProcessWaitArguments, new FileDescriptorInfo[0], creat
ionParams); |
| 393 | 395 |
| 394 CriteriaHelper.pollInstrumentationThread( | 396 CriteriaHelper.pollInstrumentationThread( |
| 395 new Criteria("Failed waiting for instrumentation-bound service")
{ | 397 new Criteria("Failed waiting for instrumentation-bound service")
{ |
| 396 @Override | 398 @Override |
| 397 public boolean isSatisfied() { | 399 public boolean isSatisfied() { |
| 398 return conn.getService() != null; | 400 return conn.getService() != null; |
| 399 } | 401 } |
| 400 }); | 402 }); |
| 401 | 403 |
| 402 assertEquals(0, conn.getServiceNumber()); | 404 assertEquals(0, conn.getServiceNumber()); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 * Returns the number of Chrome's sandboxed connections. | 527 * Returns the number of Chrome's sandboxed connections. |
| 526 */ | 528 */ |
| 527 private int allocatedChromeSandboxedConnectionsCount() { | 529 private int allocatedChromeSandboxedConnectionsCount() { |
| 528 Context context = getInstrumentation().getTargetContext(); | 530 Context context = getInstrumentation().getTargetContext(); |
| 529 return ChildProcessLauncher.allocatedSandboxedConnectionsCountForTesting
( | 531 return ChildProcessLauncher.allocatedSandboxedConnectionsCountForTesting
( |
| 530 context, context.getPackageName()); | 532 context, context.getPackageName()); |
| 531 } | 533 } |
| 532 | 534 |
| 533 private ChildProcessCreationParams getDefaultChildProcessCreationParams(Stri
ng packageName) { | 535 private ChildProcessCreationParams getDefaultChildProcessCreationParams(Stri
ng packageName) { |
| 534 return new ChildProcessCreationParams(packageName, false /* isExternalSe
rvice */, | 536 return new ChildProcessCreationParams(packageName, false /* isExternalSe
rvice */, |
| 535 LibraryProcessType.PROCESS_CHILD); | 537 LibraryProcessType.PROCESS_CHILD, false /* bindToCallerCheck */)
; |
| 536 } | 538 } |
| 537 | 539 |
| 538 private void triggerConnectionSetup(ChildProcessConnectionImpl connection) { | 540 private void triggerConnectionSetup(ChildProcessConnectionImpl connection) { |
| 539 ChildProcessLauncher.triggerConnectionSetup(connection, sProcessWaitArgu
ments, 1, | 541 ChildProcessLauncher.triggerConnectionSetup(connection, sProcessWaitArgu
ments, 1, |
| 540 new FileDescriptorInfo[0], ChildProcessLauncher.CALLBACK_FOR_REN
DERER_PROCESS, 0); | 542 new FileDescriptorInfo[0], ChildProcessLauncher.CALLBACK_FOR_REN
DERER_PROCESS, 0); |
| 541 } | 543 } |
| 542 } | 544 } |
| OLD | NEW |