| 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.chrome.browser.invalidation; | 5 package org.chromium.chrome.browser.invalidation; |
| 6 | 6 |
| 7 import android.app.Service; | 7 import android.app.Service; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.os.IBinder; | 10 import android.os.IBinder; |
| 11 | 11 |
| 12 import org.chromium.chrome.browser.init.ProcessInitializationHandler; | 12 import org.chromium.chrome.browser.init.ProcessInitializationHandler; |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * A Service that provides access to {@link ChromeBrowserSyncAdapter}. | 15 * A Service that provides access to {@link ChromeBrowserSyncAdapter}. |
| 16 */ | 16 */ |
| 17 public class ChromeBrowserSyncAdapterService extends Service { | 17 public class ChromeBrowserSyncAdapterService extends Service { |
| 18 private static ChromeBrowserSyncAdapter sSyncAdapter = null; | 18 private static ChromeBrowserSyncAdapter sSyncAdapter; |
| 19 private static final Object LOCK = new Object(); | 19 private static final Object LOCK = new Object(); |
| 20 | 20 |
| 21 /** | 21 /** |
| 22 * Get the sync adapter reference, creating an instance if necessary. | 22 * Get the sync adapter reference, creating an instance if necessary. |
| 23 */ | 23 */ |
| 24 private ChromeBrowserSyncAdapter getOrCreateSyncAdapter(Context applicationC
ontext) { | 24 private ChromeBrowserSyncAdapter getOrCreateSyncAdapter(Context applicationC
ontext) { |
| 25 synchronized (LOCK) { | 25 synchronized (LOCK) { |
| 26 if (sSyncAdapter == null) { | 26 if (sSyncAdapter == null) { |
| 27 ProcessInitializationHandler.getInstance().initializePreNative()
; | 27 ProcessInitializationHandler.getInstance().initializePreNative()
; |
| 28 sSyncAdapter = new ChromeBrowserSyncAdapter(applicationContext,
getApplication()); | 28 sSyncAdapter = new ChromeBrowserSyncAdapter(applicationContext,
getApplication()); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 return sSyncAdapter; | 31 return sSyncAdapter; |
| 32 } | 32 } |
| 33 | 33 |
| 34 @Override | 34 @Override |
| 35 public IBinder onBind(Intent intent) { | 35 public IBinder onBind(Intent intent) { |
| 36 return getOrCreateSyncAdapter(getApplicationContext()).getSyncAdapterBin
der(); | 36 return getOrCreateSyncAdapter(getApplicationContext()).getSyncAdapterBin
der(); |
| 37 } | 37 } |
| 38 } | 38 } |
| OLD | NEW |