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