OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.chrome.browser.sync; | |
6 | |
7 import android.app.Application; | |
8 import android.app.Service; | |
9 import android.content.Context; | |
10 import android.content.Intent; | |
11 import android.os.IBinder; | |
12 | |
13 public abstract class ChromiumSyncAdapterService extends Service { | |
14 private static ChromiumSyncAdapter sSyncAdapter = null; | |
15 private static final Object LOCK = new Object(); | |
16 | |
17 /** | |
18 * Get the sync adapter reference, creating an instance if necessary. | |
19 */ | |
20 private ChromiumSyncAdapter getOrCreateSyncAdapter(Context applicationContex
t) { | |
21 synchronized (LOCK) { | |
22 if (sSyncAdapter == null) { | |
23 sSyncAdapter = createChromiumSyncAdapter(applicationContext, get
Application()); | |
24 } | |
25 } | |
26 return sSyncAdapter; | |
27 } | |
28 | |
29 @Override | |
30 public IBinder onBind(Intent intent) { | |
31 return getOrCreateSyncAdapter(getApplicationContext()).getSyncAdapterBin
der(); | |
32 } | |
33 | |
34 protected abstract ChromiumSyncAdapter createChromiumSyncAdapter(Context app
licationContext, | |
35 Application
application); | |
36 } | |
OLD | NEW |