OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.net; |
| 6 |
| 7 import android.content.Context; |
| 8 import android.util.Log; |
| 9 |
| 10 /** |
| 11 * Provides context for the native HTTP operations. |
| 12 */ |
| 13 public class ChromiumUrlRequestContext extends UrlRequestContext { |
| 14 private static final Object sLock = new Object(); |
| 15 |
| 16 private static final String TAG = "ChromiumNetwork"; |
| 17 |
| 18 private static ChromiumUrlRequestContext sInstance; |
| 19 |
| 20 private ChromiumUrlRequestContext(Context context, String userAgent, |
| 21 int loggingLevel) { |
| 22 super(context, userAgent, loggingLevel); |
| 23 } |
| 24 |
| 25 public static ChromiumUrlRequestContext getInstance( |
| 26 Context context) { |
| 27 synchronized (sLock) { |
| 28 if (sInstance == null) { |
| 29 int loggingLevel; |
| 30 if (Log.isLoggable(TAG, Log.VERBOSE)) { |
| 31 loggingLevel = LOG_VERBOSE; |
| 32 } else if (Log.isLoggable(TAG, Log.DEBUG)) { |
| 33 loggingLevel = LOG_DEBUG; |
| 34 } else { |
| 35 loggingLevel = LOG_NONE; |
| 36 } |
| 37 sInstance = new ChromiumUrlRequestContext( |
| 38 context.getApplicationContext(), |
| 39 UserAgent.from(context), |
| 40 loggingLevel); |
| 41 } |
| 42 } |
| 43 return sInstance; |
| 44 } |
| 45 } |
OLD | NEW |