Home | History | Annotate | Download | only in net
      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 
      9 import java.nio.channels.WritableByteChannel;
     10 import java.util.Map;
     11 
     12 /**
     13  * Network request using {@link java.net.HttpURLConnection}.
     14  */
     15 class HttpUrlConnectionUrlRequestFactory extends HttpUrlRequestFactory {
     16 
     17     private final Context mContext;
     18 
     19     public HttpUrlConnectionUrlRequestFactory(
     20             Context context, HttpUrlRequestFactoryConfig config) {
     21         mContext = context.getApplicationContext();
     22     }
     23 
     24     @Override
     25     public boolean isEnabled() {
     26         return true;
     27     }
     28 
     29     @Override
     30     public String getName() {
     31         return "HttpUrlConnection/" + Version.getVersion();
     32     }
     33 
     34     @Override
     35     public HttpUrlRequest createRequest(String url, int requestPriority,
     36             Map<String, String> headers, HttpUrlRequestListener listener) {
     37         return new HttpUrlConnectionUrlRequest(mContext, url, requestPriority,
     38                 headers, listener);
     39     }
     40 
     41     @Override
     42     public HttpUrlRequest createRequest(String url, int requestPriority,
     43             Map<String, String> headers, WritableByteChannel channel,
     44             HttpUrlRequestListener listener) {
     45         return new HttpUrlConnectionUrlRequest(mContext, url, requestPriority,
     46                 headers, channel, listener);
     47     }
     48 }
     49