OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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; |
11 import android.content.pm.PackageManager; | 11 import android.content.pm.PackageManager; |
12 import android.content.pm.ServiceInfo; | 12 import android.content.pm.ServiceInfo; |
13 import android.os.Build; | 13 import android.os.Build; |
14 import android.os.Bundle; | 14 import android.os.Bundle; |
15 import android.os.DeadObjectException; | 15 import android.os.DeadObjectException; |
16 import android.os.IBinder; | 16 import android.os.IBinder; |
17 import android.os.RemoteException; | 17 import android.os.RemoteException; |
18 | 18 |
19 import org.chromium.base.Log; | 19 import org.chromium.base.Log; |
20 import org.chromium.base.ThreadUtils; | 20 import org.chromium.base.ThreadUtils; |
21 import org.chromium.base.TraceEvent; | 21 import org.chromium.base.TraceEvent; |
22 import org.chromium.base.VisibleForTesting; | 22 import org.chromium.base.VisibleForTesting; |
23 import org.chromium.base.process_launcher.ChildProcessCreationParams; | 23 import org.chromium.base.process_launcher.ChildProcessCreationParams; |
24 import org.chromium.content.common.FileDescriptorInfo; | 24 import org.chromium.base.process_launcher.FileDescriptorInfo; |
25 import org.chromium.content.common.IChildProcessCallback; | 25 import org.chromium.content.common.IChildProcessCallback; |
26 import org.chromium.content.common.IChildProcessService; | 26 import org.chromium.content.common.IChildProcessService; |
27 | 27 |
28 import java.io.IOException; | 28 import java.io.IOException; |
29 | 29 |
30 /** | 30 /** |
31 * Manages a connection between the browser activity and a child service. | 31 * Manages a connection between the browser activity and a child service. |
32 */ | 32 */ |
33 public class ChildProcessConnectionImpl implements ChildProcessConnection { | 33 public class ChildProcessConnectionImpl implements ChildProcessConnection { |
34 private final Context mContext; | 34 private final Context mContext; |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 mConnectionParams.mCommandLine, mConnectionParams.mFilesToBe
Mapped); | 403 mConnectionParams.mCommandLine, mConnectionParams.mFilesToBe
Mapped); |
404 try { | 404 try { |
405 mPid = mService.setupConnection(bundle, mConnectionParams.mCallb
ack); | 405 mPid = mService.setupConnection(bundle, mConnectionParams.mCallb
ack); |
406 assert mPid != 0 : "Child service claims to be run by a process
of pid=0."; | 406 assert mPid != 0 : "Child service claims to be run by a process
of pid=0."; |
407 } catch (android.os.RemoteException re) { | 407 } catch (android.os.RemoteException re) { |
408 Log.e(TAG, "Failed to setup connection.", re); | 408 Log.e(TAG, "Failed to setup connection.", re); |
409 } | 409 } |
410 // We proactively close the FDs rather than wait for GC & finalizer. | 410 // We proactively close the FDs rather than wait for GC & finalizer. |
411 try { | 411 try { |
412 for (FileDescriptorInfo fileInfo : mConnectionParams.mFilesToBeM
apped) { | 412 for (FileDescriptorInfo fileInfo : mConnectionParams.mFilesToBeM
apped) { |
413 fileInfo.mFd.close(); | 413 fileInfo.fd.close(); |
414 } | 414 } |
415 } catch (IOException ioe) { | 415 } catch (IOException ioe) { |
416 Log.w(TAG, "Failed to close FD.", ioe); | 416 Log.w(TAG, "Failed to close FD.", ioe); |
417 } | 417 } |
418 mConnectionParams = null; | 418 mConnectionParams = null; |
419 | 419 |
420 if (mConnectionCallback != null) { | 420 if (mConnectionCallback != null) { |
421 mConnectionCallback.onConnected(mPid); | 421 mConnectionCallback.onConnected(mPid); |
422 } | 422 } |
423 mConnectionCallback = null; | 423 mConnectionCallback = null; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 return true; | 546 return true; |
547 } | 547 } |
548 return false; | 548 return false; |
549 } | 549 } |
550 | 550 |
551 @VisibleForTesting | 551 @VisibleForTesting |
552 public boolean isConnected() { | 552 public boolean isConnected() { |
553 return mService != null; | 553 return mService != null; |
554 } | 554 } |
555 } | 555 } |
OLD | NEW |