summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 21:36:19 +0000
committermef@chromium.org <mef@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-08 21:37:48 +0000
commitfa5f474c5b3389be8dd6929d3284ce15ea330504 (patch)
tree9bb82509a0586caa280fc6621fcefdca6694b998
parent8cf6f84925a99cc01f1d125339c24fe052dd2a4c (diff)
downloadchromium_src-fa5f474c5b3389be8dd6929d3284ce15ea330504.zip
chromium_src-fa5f474c5b3389be8dd6929d3284ce15ea330504.tar.gz
chromium_src-fa5f474c5b3389be8dd6929d3284ce15ea330504.tar.bz2
Rename url_request_[context_]peer.* into url_request_[context_]adapter.*
BUG=390267 Review URL: https://codereview.chromium.org/453053002 Cr-Commit-Position: refs/heads/master@{#288441} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288441 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--components/cronet.gypi8
-rw-r--r--components/cronet/android/java/src/org/chromium/net/UrlRequest.java75
-rw-r--r--components/cronet/android/java/src/org/chromium/net/UrlRequestContext.java34
-rw-r--r--components/cronet/android/org_chromium_net_UrlRequest.cc128
-rw-r--r--components/cronet/android/org_chromium_net_UrlRequestContext.cc74
-rw-r--r--components/cronet/android/url_request_adapter.cc (renamed from components/cronet/android/url_request_peer.cc)83
-rw-r--r--components/cronet/android/url_request_adapter.h (renamed from components/cronet/android/url_request_peer.h)42
-rw-r--r--components/cronet/android/url_request_context_adapter.cc (renamed from components/cronet/android/url_request_context_peer.cc)32
-rw-r--r--components/cronet/android/url_request_context_adapter.h (renamed from components/cronet/android/url_request_context_peer.h)28
-rw-r--r--components/cronet/android/wrapped_channel_upload_element_reader.cc2
-rw-r--r--components/cronet/android/wrapped_channel_upload_element_reader.h6
11 files changed, 269 insertions, 243 deletions
diff --git a/components/cronet.gypi b/components/cronet.gypi
index 2915571..c0dfb33 100644
--- a/components/cronet.gypi
+++ b/components/cronet.gypi
@@ -118,10 +118,10 @@
'cronet/android/org_chromium_net_UrlRequestContext.cc',
'cronet/android/org_chromium_net_UrlRequestContext.h',
'cronet/android/org_chromium_net_UrlRequestContext_config_list.h',
- 'cronet/android/url_request_context_peer.cc',
- 'cronet/android/url_request_context_peer.h',
- 'cronet/android/url_request_peer.cc',
- 'cronet/android/url_request_peer.h',
+ 'cronet/android/url_request_adapter.cc',
+ 'cronet/android/url_request_adapter.h',
+ 'cronet/android/url_request_context_adapter.cc',
+ 'cronet/android/url_request_context_adapter.h',
'cronet/android/wrapped_channel_upload_element_reader.cc',
'cronet/android/wrapped_channel_upload_element_reader.h',
],
diff --git a/components/cronet/android/java/src/org/chromium/net/UrlRequest.java b/components/cronet/android/java/src/org/chromium/net/UrlRequest.java
index 7cf9ef4..73e9aba 100644
--- a/components/cronet/android/java/src/org/chromium/net/UrlRequest.java
+++ b/components/cronet/android/java/src/org/chromium/net/UrlRequest.java
@@ -52,9 +52,9 @@ public class UrlRequest {
private final ContextLock mLock;
/**
- * Native peer object, owned by UrlRequest.
+ * Native adapter object, owned by UrlRequest.
*/
- private long mUrlRequestPeer;
+ private long mUrlRequestAdapter;
/**
* Constructor.
@@ -81,8 +81,8 @@ public class UrlRequest {
mHeaders = headers;
mSink = sink;
mLock = new ContextLock();
- mUrlRequestPeer = nativeCreateRequestPeer(
- mRequestContext.getUrlRequestContextPeer(), mUrl, mPriority);
+ mUrlRequestAdapter = nativeCreateRequestAdapter(
+ mRequestContext.getUrlRequestContextAdapter(), mUrl, mPriority);
}
/**
@@ -136,7 +136,7 @@ public class UrlRequest {
public void setHttpMethod(String method) {
validateNotStarted();
if (!("PUT".equals(method) || "POST".equals(method))) {
- throw new IllegalArgumentException("Only PUT and POST are allowed.");
+ throw new IllegalArgumentException("Only PUT or POST are allowed.");
}
mMethod = method;
}
@@ -166,12 +166,12 @@ public class UrlRequest {
}
if (method != null) {
- nativeSetMethod(mUrlRequestPeer, method);
+ nativeSetMethod(mUrlRequestAdapter, method);
}
if (mHeaders != null && !mHeaders.isEmpty()) {
for (Entry<String, String> entry : mHeaders.entrySet()) {
- nativeAddHeader(mUrlRequestPeer, entry.getKey(),
+ nativeAddHeader(mUrlRequestAdapter, entry.getKey(),
entry.getValue());
}
}
@@ -179,20 +179,20 @@ public class UrlRequest {
if (mAdditionalHeaders != null) {
for (Entry<String, String> entry :
mAdditionalHeaders.entrySet()) {
- nativeAddHeader(mUrlRequestPeer, entry.getKey(),
+ nativeAddHeader(mUrlRequestAdapter, entry.getKey(),
entry.getValue());
}
}
if (mUploadData != null && mUploadData.length > 0) {
- nativeSetUploadData(mUrlRequestPeer, mUploadContentType,
+ nativeSetUploadData(mUrlRequestAdapter, mUploadContentType,
mUploadData);
} else if (mUploadChannel != null) {
- nativeSetUploadChannel(mUrlRequestPeer, mUploadContentType,
+ nativeSetUploadChannel(mUrlRequestAdapter, mUploadContentType,
mUploadContentLength);
}
- nativeStart(mUrlRequestPeer);
+ nativeStart(mUrlRequestAdapter);
}
}
@@ -205,7 +205,7 @@ public class UrlRequest {
mCanceled = true;
if (!mRecycled) {
- nativeCancel(mUrlRequestPeer);
+ nativeCancel(mUrlRequestAdapter);
}
}
}
@@ -233,12 +233,13 @@ public class UrlRequest {
validateNotRecycled();
- int errorCode = nativeGetErrorCode(mUrlRequestPeer);
+ int errorCode = nativeGetErrorCode(mUrlRequestAdapter);
switch (errorCode) {
case UrlRequestError.SUCCESS:
return null;
case UrlRequestError.UNKNOWN:
- return new IOException(nativeGetErrorString(mUrlRequestPeer));
+ return new IOException(
+ nativeGetErrorString(mUrlRequestAdapter));
case UrlRequestError.MALFORMED_URL:
return new MalformedURLException("Malformed URL: " + mUrl);
case UrlRequestError.CONNECTION_TIMED_OUT:
@@ -258,7 +259,7 @@ public class UrlRequest {
}
public int getHttpStatusCode() {
- return nativeGetHttpStatusCode(mUrlRequestPeer);
+ return nativeGetHttpStatusCode(mUrlRequestAdapter);
}
/**
@@ -275,14 +276,14 @@ public class UrlRequest {
public String getHeader(String name) {
validateHeadersAvailable();
- return nativeGetHeader(mUrlRequestPeer, name);
+ return nativeGetHeader(mUrlRequestAdapter, name);
}
// All response headers.
public Map<String, List<String>> getAllHeaders() {
validateHeadersAvailable();
ResponseHeadersMap result = new ResponseHeadersMap();
- nativeGetAllHeaders(mUrlRequestPeer, result);
+ nativeGetAllHeaders(mUrlRequestAdapter, result);
return result;
}
@@ -291,8 +292,8 @@ public class UrlRequest {
*/
@CalledByNative
protected void onResponseStarted() {
- mContentType = nativeGetContentType(mUrlRequestPeer);
- mContentLength = nativeGetContentLength(mUrlRequestPeer);
+ mContentType = nativeGetContentType(mUrlRequestAdapter);
+ mContentLength = nativeGetContentLength(mUrlRequestAdapter);
mHeadersAvailable = true;
}
@@ -339,8 +340,8 @@ public class UrlRequest {
// Ignore
}
onRequestComplete();
- nativeDestroyRequestPeer(mUrlRequestPeer);
- mUrlRequestPeer = 0;
+ nativeDestroyRequestAdapter(mUrlRequestAdapter);
+ mUrlRequestAdapter = 0;
mRecycled = true;
}
}
@@ -410,39 +411,39 @@ public class UrlRequest {
return mUrl;
}
- private native long nativeCreateRequestPeer(long urlRequestContextPeer,
- String url, int priority);
+ private native long nativeCreateRequestAdapter(
+ long urlRequestContextAdapter, String url, int priority);
- private native void nativeAddHeader(long urlRequestPeer, String name,
+ private native void nativeAddHeader(long urlRequestAdapter, String name,
String value);
- private native void nativeSetMethod(long urlRequestPeer, String method);
+ private native void nativeSetMethod(long urlRequestAdapter, String method);
- private native void nativeSetUploadData(long urlRequestPeer,
+ private native void nativeSetUploadData(long urlRequestAdapter,
String contentType, byte[] content);
- private native void nativeSetUploadChannel(long urlRequestPeer,
+ private native void nativeSetUploadChannel(long urlRequestAdapter,
String contentType, long contentLength);
- private native void nativeStart(long urlRequestPeer);
+ private native void nativeStart(long urlRequestAdapter);
- private native void nativeCancel(long urlRequestPeer);
+ private native void nativeCancel(long urlRequestAdapter);
- private native void nativeDestroyRequestPeer(long urlRequestPeer);
+ private native void nativeDestroyRequestAdapter(long urlRequestAdapter);
- private native int nativeGetErrorCode(long urlRequestPeer);
+ private native int nativeGetErrorCode(long urlRequestAdapter);
- private native int nativeGetHttpStatusCode(long urlRequestPeer);
+ private native int nativeGetHttpStatusCode(long urlRequestAdapter);
- private native String nativeGetErrorString(long urlRequestPeer);
+ private native String nativeGetErrorString(long urlRequestAdapter);
- private native String nativeGetContentType(long urlRequestPeer);
+ private native String nativeGetContentType(long urlRequestAdapter);
- private native long nativeGetContentLength(long urlRequestPeer);
+ private native long nativeGetContentLength(long urlRequestAdapter);
- private native String nativeGetHeader(long urlRequestPeer, String name);
+ private native String nativeGetHeader(long urlRequestAdapter, String name);
- private native void nativeGetAllHeaders(long urlRequestPeer,
+ private native void nativeGetAllHeaders(long urlRequestAdapter,
ResponseHeadersMap headers);
// Explicit class to work around JNI-generator generics confusion.
diff --git a/components/cronet/android/java/src/org/chromium/net/UrlRequestContext.java b/components/cronet/android/java/src/org/chromium/net/UrlRequestContext.java
index d20f0a3..7faf184 100644
--- a/components/cronet/android/java/src/org/chromium/net/UrlRequestContext.java
+++ b/components/cronet/android/java/src/org/chromium/net/UrlRequestContext.java
@@ -23,9 +23,9 @@ public class UrlRequestContext {
private static final String LOG_TAG = "ChromiumNetwork";
/**
- * Native peer object, owned by UrlRequestContext.
+ * Native adapter object, owned by UrlRequestContext.
*/
- private long mUrlRequestContextPeer;
+ private long mUrlRequestContextAdapter;
private final ConditionVariable mStarted = new ConditionVariable();
@@ -35,10 +35,10 @@ public class UrlRequestContext {
*/
protected UrlRequestContext(Context context, String userAgent,
String config) {
- mUrlRequestContextPeer = nativeCreateRequestContextPeer(context,
+ mUrlRequestContextAdapter = nativeCreateRequestContextAdapter(context,
userAgent, getLoggingLevel(), config);
- if (mUrlRequestContextPeer == 0)
- throw new NullPointerException("Context Peer creation failed");
+ if (mUrlRequestContextAdapter == 0)
+ throw new NullPointerException("Context Adapter creation failed");
// TODO(mef): Revisit the need of block here.
mStarted.block(2000);
@@ -75,7 +75,7 @@ public class UrlRequestContext {
* If actively logging the call is ignored.
*/
public void startNetLogToFile(String fileName) {
- nativeStartNetLogToFile(mUrlRequestContextPeer, fileName);
+ nativeStartNetLogToFile(mUrlRequestContextAdapter, fileName);
}
/**
@@ -83,7 +83,7 @@ public class UrlRequestContext {
* not in progress this call is ignored.
*/
public void stopNetLog() {
- nativeStopNetLog(mUrlRequestContextPeer);
+ nativeStopNetLog(mUrlRequestContextAdapter);
}
@CalledByNative
@@ -95,12 +95,12 @@ public class UrlRequestContext {
@Override
protected void finalize() throws Throwable {
- nativeReleaseRequestContextPeer(mUrlRequestContextPeer);
+ nativeReleaseRequestContextAdapter(mUrlRequestContextAdapter);
super.finalize();
}
- protected long getUrlRequestContextPeer() {
- return mUrlRequestContextPeer;
+ protected long getUrlRequestContextAdapter() {
+ return mUrlRequestContextAdapter;
}
/**
@@ -119,20 +119,20 @@ public class UrlRequestContext {
return loggingLevel;
}
- // Returns an instance URLRequestContextPeer to be stored in
- // mUrlRequestContextPeer.
- private native long nativeCreateRequestContextPeer(Context context,
+ // Returns an instance URLRequestContextAdapter to be stored in
+ // mUrlRequestContextAdapter.
+ private native long nativeCreateRequestContextAdapter(Context context,
String userAgent, int loggingLevel, String config);
- private native void nativeReleaseRequestContextPeer(
- long urlRequestContextPeer);
+ private native void nativeReleaseRequestContextAdapter(
+ long urlRequestContextAdapter);
private native void nativeInitializeStatistics();
private native String nativeGetStatisticsJSON(String filter);
- private native void nativeStartNetLogToFile(long urlRequestContextPeer,
+ private native void nativeStartNetLogToFile(long urlRequestContextAdapter,
String fileName);
- private native void nativeStopNetLog(long urlRequestContextPeer);
+ private native void nativeStopNetLog(long urlRequestContextAdapter);
}
diff --git a/components/cronet/android/org_chromium_net_UrlRequest.cc b/components/cronet/android/org_chromium_net_UrlRequest.cc
index 0f9ea64..e38f93f 100644
--- a/components/cronet/android/org_chromium_net_UrlRequest.cc
+++ b/components/cronet/android/org_chromium_net_UrlRequest.cc
@@ -7,8 +7,8 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/macros.h"
-#include "components/cronet/android/url_request_context_peer.h"
-#include "components/cronet/android/url_request_peer.h"
+#include "components/cronet/android/url_request_adapter.h"
+#include "components/cronet/android/url_request_context_adapter.h"
#include "jni/UrlRequest_jni.h"
#include "net/base/net_errors.h"
#include "net/base/request_priority.h"
@@ -37,7 +37,7 @@ net::RequestPriority ConvertRequestPriority(jint request_priority) {
}
void SetPostContentType(JNIEnv* env,
- URLRequestPeer* request,
+ URLRequestAdapter* request,
jstring content_type) {
DCHECK(request != NULL);
@@ -53,20 +53,20 @@ void SetPostContentType(JNIEnv* env,
request->AddHeader(content_type_header, content_type_string);
}
-// A delegate of URLRequestPeer that delivers callbacks to the Java layer.
-class JniURLRequestPeerDelegate
- : public URLRequestPeer::URLRequestPeerDelegate {
+// A delegate of URLRequestAdapter that delivers callbacks to the Java layer.
+class JniURLRequestAdapterDelegate
+ : public URLRequestAdapter::URLRequestAdapterDelegate {
public:
- JniURLRequestPeerDelegate(JNIEnv* env, jobject owner) {
+ JniURLRequestAdapterDelegate(JNIEnv* env, jobject owner) {
owner_ = env->NewGlobalRef(owner);
}
- virtual void OnResponseStarted(URLRequestPeer* request) OVERRIDE {
+ virtual void OnResponseStarted(URLRequestAdapter* request) OVERRIDE {
JNIEnv* env = base::android::AttachCurrentThread();
cronet::Java_UrlRequest_onResponseStarted(env, owner_);
}
- virtual void OnBytesRead(URLRequestPeer* request) OVERRIDE {
+ virtual void OnBytesRead(URLRequestAdapter* request) OVERRIDE {
int bytes_read = request->bytes_read();
if (bytes_read != 0) {
JNIEnv* env = base::android::AttachCurrentThread();
@@ -76,7 +76,7 @@ class JniURLRequestPeerDelegate
}
}
- virtual void OnRequestFinished(URLRequestPeer* request) OVERRIDE {
+ virtual void OnRequestFinished(URLRequestAdapter* request) OVERRIDE {
JNIEnv* env = base::android::AttachCurrentThread();
cronet::Java_UrlRequest_finish(env, owner_);
}
@@ -92,7 +92,7 @@ class JniURLRequestPeerDelegate
}
protected:
- virtual ~JniURLRequestPeerDelegate() {
+ virtual ~JniURLRequestAdapterDelegate() {
JNIEnv* env = base::android::AttachCurrentThread();
env->DeleteGlobalRef(owner_);
}
@@ -100,7 +100,7 @@ class JniURLRequestPeerDelegate
private:
jobject owner_;
- DISALLOW_COPY_AND_ASSIGN(JniURLRequestPeerDelegate);
+ DISALLOW_COPY_AND_ASSIGN(JniURLRequestAdapterDelegate);
};
} // namespace
@@ -108,13 +108,13 @@ class JniURLRequestPeerDelegate
// Explicitly register static JNI functions.
bool UrlRequestRegisterJni(JNIEnv* env) { return RegisterNativesImpl(env); }
-static jlong CreateRequestPeer(JNIEnv* env,
- jobject object,
- jlong urlRequestContextPeer,
- jstring url_string,
- jint priority) {
- URLRequestContextPeer* context =
- reinterpret_cast<URLRequestContextPeer*>(urlRequestContextPeer);
+static jlong CreateRequestAdapter(JNIEnv* env,
+ jobject object,
+ jlong urlRequestContextAdapter,
+ jstring url_string,
+ jint priority) {
+ URLRequestContextAdapter* context =
+ reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter);
DCHECK(context != NULL);
const char* url_utf8 = env->GetStringUTFChars(url_string, NULL);
@@ -125,22 +125,23 @@ static jlong CreateRequestPeer(JNIEnv* env,
env->ReleaseStringUTFChars(url_string, url_utf8);
- URLRequestPeer* peer =
- new URLRequestPeer(context,
- new JniURLRequestPeerDelegate(env, object),
- url,
- ConvertRequestPriority(priority));
+ URLRequestAdapter* adapter =
+ new URLRequestAdapter(context,
+ new JniURLRequestAdapterDelegate(env, object),
+ url,
+ ConvertRequestPriority(priority));
- return reinterpret_cast<jlong>(peer);
+ return reinterpret_cast<jlong>(adapter);
}
// synchronized
static void AddHeader(JNIEnv* env,
jobject object,
- jlong urlRequestPeer,
+ jlong urlRequestAdapter,
jstring name,
jstring value) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
DCHECK(request);
std::string name_string(base::android::ConvertJavaStringToUTF8(env, name));
@@ -151,9 +152,10 @@ static void AddHeader(JNIEnv* env,
static void SetMethod(JNIEnv* env,
jobject object,
- jlong urlRequestPeer,
+ jlong urlRequestAdapter,
jstring method) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
DCHECK(request);
std::string method_string(
@@ -164,10 +166,11 @@ static void SetMethod(JNIEnv* env,
static void SetUploadData(JNIEnv* env,
jobject object,
- jlong urlRequestPeer,
+ jlong urlRequestAdapter,
jstring content_type,
jbyteArray content) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
SetPostContentType(env, request, content_type);
if (content != NULL) {
@@ -183,10 +186,11 @@ static void SetUploadData(JNIEnv* env,
static void SetUploadChannel(JNIEnv* env,
jobject object,
- jlong urlRequestPeer,
+ jlong urlRequestAdapter,
jstring content_type,
jlong content_length) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
SetPostContentType(env, request, content_type);
request->SetUploadChannel(env, content_length);
@@ -194,33 +198,37 @@ static void SetUploadChannel(JNIEnv* env,
/* synchronized */
-static void Start(JNIEnv* env, jobject object, jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+static void Start(JNIEnv* env, jobject object, jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request != NULL) {
request->Start();
}
}
/* synchronized */
-static void DestroyRequestPeer(JNIEnv* env,
- jobject object,
- jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+static void DestroyRequestAdapter(JNIEnv* env,
+ jobject object,
+ jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request != NULL) {
request->Destroy();
}
}
/* synchronized */
-static void Cancel(JNIEnv* env, jobject object, jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+static void Cancel(JNIEnv* env, jobject object, jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request != NULL) {
request->Cancel();
}
}
-static jint GetErrorCode(JNIEnv* env, jobject object, jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+static jint GetErrorCode(JNIEnv* env, jobject object, jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
int error_code = request->error_code();
switch (error_code) {
// TODO(mef): Investigate returning success on positive values, too, as
@@ -256,8 +264,9 @@ static jint GetErrorCode(JNIEnv* env, jobject object, jlong urlRequestPeer) {
static jstring GetErrorString(JNIEnv* env,
jobject object,
- jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
int error_code = request->error_code();
char buffer[200];
std::string error_string = net::ErrorToString(error_code);
@@ -271,15 +280,17 @@ static jstring GetErrorString(JNIEnv* env,
static jint GetHttpStatusCode(JNIEnv* env,
jobject object,
- jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
return request->http_status_code();
}
static jstring GetContentType(JNIEnv* env,
jobject object,
- jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request == NULL) {
return NULL;
}
@@ -293,17 +304,21 @@ static jstring GetContentType(JNIEnv* env,
static jlong GetContentLength(JNIEnv* env,
jobject object,
- jlong urlRequestPeer) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ jlong urlRequestAdapter) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request == NULL) {
return 0;
}
return request->content_length();
}
-static jstring GetHeader(
- JNIEnv* env, jobject object, jlong urlRequestPeer, jstring name) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+static jstring GetHeader(JNIEnv* env,
+ jobject object,
+ jlong urlRequestAdapter,
+ jstring name) {
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request == NULL) {
return NULL;
}
@@ -319,9 +334,10 @@ static jstring GetHeader(
static void GetAllHeaders(JNIEnv* env,
jobject object,
- jlong urlRequestPeer,
+ jlong urlRequestAdapter,
jobject headersMap) {
- URLRequestPeer* request = reinterpret_cast<URLRequestPeer*>(urlRequestPeer);
+ URLRequestAdapter* request =
+ reinterpret_cast<URLRequestAdapter*>(urlRequestAdapter);
if (request == NULL)
return;
diff --git a/components/cronet/android/org_chromium_net_UrlRequestContext.cc b/components/cronet/android/org_chromium_net_UrlRequestContext.cc
index b378c28..ae6cd2a 100644
--- a/components/cronet/android/org_chromium_net_UrlRequestContext.cc
+++ b/components/cronet/android/org_chromium_net_UrlRequestContext.cc
@@ -14,23 +14,24 @@
#include "base/metrics/statistics_recorder.h"
#include "base/values.h"
#include "components/cronet/android/org_chromium_net_UrlRequest.h"
-#include "components/cronet/android/url_request_context_peer.h"
-#include "components/cronet/android/url_request_peer.h"
+#include "components/cronet/android/url_request_adapter.h"
+#include "components/cronet/android/url_request_context_adapter.h"
#include "components/cronet/url_request_context_config.h"
#include "jni/UrlRequestContext_jni.h"
namespace {
-// Delegate of URLRequestContextPeer that delivers callbacks to the Java layer.
-class JniURLRequestContextPeerDelegate
- : public cronet::URLRequestContextPeer::URLRequestContextPeerDelegate {
+// Delegate of URLRequestContextAdapter that delivers callbacks to the Java
+// layer.
+class JniURLRequestContextAdapterDelegate
+ : public cronet::URLRequestContextAdapter::
+ URLRequestContextAdapterDelegate {
public:
- JniURLRequestContextPeerDelegate(JNIEnv* env, jobject owner)
- : owner_(env->NewGlobalRef(owner)) {
- }
+ JniURLRequestContextAdapterDelegate(JNIEnv* env, jobject owner)
+ : owner_(env->NewGlobalRef(owner)) {}
virtual void OnContextInitialized(
- cronet::URLRequestContextPeer* context) OVERRIDE {
+ cronet::URLRequestContextAdapter* context) OVERRIDE {
JNIEnv* env = base::android::AttachCurrentThread();
cronet::Java_UrlRequestContext_initNetworkThread(env, owner_);
// TODO(dplotnikov): figure out if we need to detach from the thread.
@@ -38,7 +39,7 @@ class JniURLRequestContextPeerDelegate
}
protected:
- virtual ~JniURLRequestContextPeerDelegate() {
+ virtual ~JniURLRequestContextAdapterDelegate() {
JNIEnv* env = base::android::AttachCurrentThread();
env->DeleteGlobalRef(owner_);
}
@@ -57,12 +58,12 @@ bool UrlRequestContextRegisterJni(JNIEnv* env) {
}
// Sets global user-agent to be used for all subsequent requests.
-static jlong CreateRequestContextPeer(JNIEnv* env,
- jobject object,
- jobject context,
- jstring user_agent,
- jint log_level,
- jstring config) {
+static jlong CreateRequestContextAdapter(JNIEnv* env,
+ jobject object,
+ jobject context,
+ jstring user_agent,
+ jint log_level,
+ jstring config) {
std::string user_agent_string =
base::android::ConvertJavaStringToUTF8(env, user_agent);
@@ -92,24 +93,25 @@ static jlong CreateRequestContextPeer(JNIEnv* env,
logging::SetMinLogLevel(static_cast<int>(log_level));
// TODO(dplotnikov): set application context.
- URLRequestContextPeer* peer = new URLRequestContextPeer(
- new JniURLRequestContextPeerDelegate(env, object), user_agent_string);
- peer->AddRef(); // Hold onto this ref-counted object.
- peer->Initialize(context_config.Pass());
- return reinterpret_cast<jlong>(peer);
+ URLRequestContextAdapter* adapter = new URLRequestContextAdapter(
+ new JniURLRequestContextAdapterDelegate(env, object), user_agent_string);
+ adapter->AddRef(); // Hold onto this ref-counted object.
+ adapter->Initialize(context_config.Pass());
+ return reinterpret_cast<jlong>(adapter);
}
// Releases native objects.
-static void ReleaseRequestContextPeer(JNIEnv* env,
- jobject object,
- jlong urlRequestContextPeer) {
- URLRequestContextPeer* peer =
- reinterpret_cast<URLRequestContextPeer*>(urlRequestContextPeer);
+static void ReleaseRequestContextAdapter(JNIEnv* env,
+ jobject object,
+ jlong urlRequestContextAdapter) {
+ URLRequestContextAdapter* adapter =
+ reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter);
// TODO(mef): Revisit this from thread safety point of view: Can we delete a
// thread while running on that thread?
- // URLRequestContextPeer is a ref-counted object, and may have pending tasks,
+ // URLRequestContextAdapter is a ref-counted object, and may have pending
+ // tasks,
// so we need to release it instead of deleting here.
- peer->Release();
+ adapter->Release();
}
// Starts recording statistics.
@@ -128,21 +130,21 @@ static jstring GetStatisticsJSON(JNIEnv* env, jobject jcaller, jstring filter) {
// Starts recording NetLog into file with |fileName|.
static void StartNetLogToFile(JNIEnv* env,
jobject jcaller,
- jlong urlRequestContextPeer,
+ jlong urlRequestContextAdapter,
jstring fileName) {
- URLRequestContextPeer* peer =
- reinterpret_cast<URLRequestContextPeer*>(urlRequestContextPeer);
+ URLRequestContextAdapter* adapter =
+ reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter);
std::string file_name = base::android::ConvertJavaStringToUTF8(env, fileName);
- peer->StartNetLogToFile(file_name);
+ adapter->StartNetLogToFile(file_name);
}
// Stops recording NetLog.
static void StopNetLog(JNIEnv* env,
jobject jcaller,
- jlong urlRequestContextPeer) {
- URLRequestContextPeer* peer =
- reinterpret_cast<URLRequestContextPeer*>(urlRequestContextPeer);
- peer->StopNetLog();
+ jlong urlRequestContextAdapter) {
+ URLRequestContextAdapter* adapter =
+ reinterpret_cast<URLRequestContextAdapter*>(urlRequestContextAdapter);
+ adapter->StopNetLog();
}
} // namespace cronet
diff --git a/components/cronet/android/url_request_peer.cc b/components/cronet/android/url_request_adapter.cc
index 5f413e6..8ab88a2 100644
--- a/components/cronet/android/url_request_peer.cc
+++ b/components/cronet/android/url_request_adapter.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "url_request_peer.h"
+#include "url_request_adapter.h"
#include "base/strings/string_number_conversions.h"
-#include "components/cronet/android/url_request_context_peer.h"
+#include "components/cronet/android/url_request_context_adapter.h"
#include "components/cronet/android/wrapped_channel_upload_element_reader.h"
#include "net/base/load_flags.h"
#include "net/base/upload_bytes_element_reader.h"
@@ -15,10 +15,10 @@ namespace cronet {
static const size_t kBufferSizeIncrement = 8192;
-URLRequestPeer::URLRequestPeer(URLRequestContextPeer* context,
- URLRequestPeerDelegate* delegate,
- GURL url,
- net::RequestPriority priority)
+URLRequestAdapter::URLRequestAdapter(URLRequestContextAdapter* context,
+ URLRequestAdapterDelegate* delegate,
+ GURL url,
+ net::RequestPriority priority)
: method_("GET"),
url_request_(NULL),
read_buffer_(new net::GrowableIOBuffer()),
@@ -27,38 +27,42 @@ URLRequestPeer::URLRequestPeer(URLRequestContextPeer* context,
error_code_(0),
http_status_code_(0),
canceled_(false),
- expected_size_(0) {
+ expected_size_(0) {
context_ = context;
delegate_ = delegate;
url_ = url;
priority_ = priority;
}
-URLRequestPeer::~URLRequestPeer() { CHECK(url_request_ == NULL); }
+URLRequestAdapter::~URLRequestAdapter() {
+ CHECK(url_request_ == NULL);
+}
-void URLRequestPeer::SetMethod(const std::string& method) { method_ = method; }
+void URLRequestAdapter::SetMethod(const std::string& method) {
+ method_ = method;
+}
-void URLRequestPeer::AddHeader(const std::string& name,
- const std::string& value) {
+void URLRequestAdapter::AddHeader(const std::string& name,
+ const std::string& value) {
headers_.SetHeader(name, value);
}
-void URLRequestPeer::SetUploadContent(const char* bytes, int bytes_len) {
+void URLRequestAdapter::SetUploadContent(const char* bytes, int bytes_len) {
std::vector<char> data(bytes, bytes + bytes_len);
scoped_ptr<net::UploadElementReader> reader(
new net::UploadOwnedBytesElementReader(&data));
- upload_data_stream_.reset(net::UploadDataStream::CreateWithReader(
- reader.Pass(), 0));
+ upload_data_stream_.reset(
+ net::UploadDataStream::CreateWithReader(reader.Pass(), 0));
}
-void URLRequestPeer::SetUploadChannel(JNIEnv* env, int64 content_length) {
+void URLRequestAdapter::SetUploadChannel(JNIEnv* env, int64 content_length) {
scoped_ptr<net::UploadElementReader> reader(
new WrappedChannelElementReader(delegate_, content_length));
- upload_data_stream_.reset(net::UploadDataStream::CreateWithReader(
- reader.Pass(), 0));
+ upload_data_stream_.reset(
+ net::UploadDataStream::CreateWithReader(reader.Pass(), 0));
}
-std::string URLRequestPeer::GetHeader(const std::string &name) const {
+std::string URLRequestAdapter::GetHeader(const std::string& name) const {
std::string value;
if (url_request_ != NULL) {
url_request_->GetResponseHeaderByName(name, &value);
@@ -66,21 +70,21 @@ std::string URLRequestPeer::GetHeader(const std::string &name) const {
return value;
}
-net::HttpResponseHeaders* URLRequestPeer::GetResponseHeaders() const {
+net::HttpResponseHeaders* URLRequestAdapter::GetResponseHeaders() const {
if (url_request_ == NULL) {
return NULL;
}
return url_request_->response_headers();
}
-void URLRequestPeer::Start() {
+void URLRequestAdapter::Start() {
context_->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&URLRequestPeer::OnInitiateConnection,
+ base::Bind(&URLRequestAdapter::OnInitiateConnection,
base::Unretained(this)));
}
-void URLRequestPeer::OnInitiateConnection() {
+void URLRequestAdapter::OnInitiateConnection() {
if (canceled_) {
return;
}
@@ -99,7 +103,7 @@ void URLRequestPeer::OnInitiateConnection() {
std::string user_agent;
user_agent = context_->GetUserAgent(url_);
url_request_->SetExtraRequestHeaderByName(
- net::HttpRequestHeaders::kUserAgent, user_agent, true /* override */);
+ net::HttpRequestHeaders::kUserAgent, user_agent, true /* override */);
}
if (upload_data_stream_)
@@ -110,7 +114,7 @@ void URLRequestPeer::OnInitiateConnection() {
url_request_->Start();
}
-void URLRequestPeer::Cancel() {
+void URLRequestAdapter::Cancel() {
if (canceled_) {
return;
}
@@ -119,10 +123,10 @@ void URLRequestPeer::Cancel() {
context_->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&URLRequestPeer::OnCancelRequest, base::Unretained(this)));
+ base::Bind(&URLRequestAdapter::OnCancelRequest, base::Unretained(this)));
}
-void URLRequestPeer::OnCancelRequest() {
+void URLRequestAdapter::OnCancelRequest() {
VLOG(1) << "Canceling chromium request: " << url_.possibly_invalid_spec();
if (url_request_ != NULL) {
@@ -132,19 +136,19 @@ void URLRequestPeer::OnCancelRequest() {
OnRequestCanceled();
}
-void URLRequestPeer::Destroy() {
+void URLRequestAdapter::Destroy() {
context_->GetNetworkTaskRunner()->PostTask(
- FROM_HERE, base::Bind(&URLRequestPeer::OnDestroyRequest, this));
+ FROM_HERE, base::Bind(&URLRequestAdapter::OnDestroyRequest, this));
}
// static
-void URLRequestPeer::OnDestroyRequest(URLRequestPeer* self) {
+void URLRequestAdapter::OnDestroyRequest(URLRequestAdapter* self) {
VLOG(1) << "Destroying chromium request: "
<< self->url_.possibly_invalid_spec();
delete self;
}
-void URLRequestPeer::OnResponseStarted(net::URLRequest* request) {
+void URLRequestAdapter::OnResponseStarted(net::URLRequest* request) {
if (request->status().status() != net::URLRequestStatus::SUCCESS) {
OnRequestFailed();
return;
@@ -161,7 +165,7 @@ void URLRequestPeer::OnResponseStarted(net::URLRequest* request) {
}
// Reads all available data or starts an asynchronous read.
-void URLRequestPeer::Read() {
+void URLRequestAdapter::Read() {
while (true) {
if (read_buffer_->RemainingCapacity() == 0) {
int new_capacity = read_buffer_->capacity() + kBufferSizeIncrement;
@@ -196,7 +200,8 @@ void URLRequestPeer::Read() {
}
}
-void URLRequestPeer::OnReadCompleted(net::URLRequest* request, int bytes_read) {
+void URLRequestAdapter::OnReadCompleted(net::URLRequest* request,
+ int bytes_read) {
VLOG(1) << "Asynchronously read: " << bytes_read << " bytes";
if (bytes_read < 0) {
OnRequestFailed();
@@ -210,13 +215,13 @@ void URLRequestPeer::OnReadCompleted(net::URLRequest* request, int bytes_read) {
Read();
}
-void URLRequestPeer::OnBytesRead(int bytes_read) {
+void URLRequestAdapter::OnBytesRead(int bytes_read) {
read_buffer_->set_offset(read_buffer_->offset() + bytes_read);
bytes_read_ += bytes_read;
total_bytes_read_ += bytes_read;
}
-void URLRequestPeer::OnRequestSucceeded() {
+void URLRequestAdapter::OnRequestSucceeded() {
if (canceled_) {
return;
}
@@ -227,7 +232,7 @@ void URLRequestPeer::OnRequestSucceeded() {
OnRequestCompleted();
}
-void URLRequestPeer::OnRequestFailed() {
+void URLRequestAdapter::OnRequestFailed() {
if (canceled_) {
return;
}
@@ -238,9 +243,11 @@ void URLRequestPeer::OnRequestFailed() {
OnRequestCompleted();
}
-void URLRequestPeer::OnRequestCanceled() { OnRequestCompleted(); }
+void URLRequestAdapter::OnRequestCanceled() {
+ OnRequestCompleted();
+}
-void URLRequestPeer::OnRequestCompleted() {
+void URLRequestAdapter::OnRequestCompleted() {
VLOG(1) << "Completed: " << url_.possibly_invalid_spec();
if (url_request_ != NULL) {
delete url_request_;
@@ -251,7 +258,7 @@ void URLRequestPeer::OnRequestCompleted() {
delegate_->OnRequestFinished(this);
}
-unsigned char* URLRequestPeer::Data() const {
+unsigned char* URLRequestAdapter::Data() const {
return reinterpret_cast<unsigned char*>(read_buffer_->StartOfBuffer());
}
diff --git a/components/cronet/android/url_request_peer.h b/components/cronet/android/url_request_adapter.h
index a6e4f9e..482f175 100644
--- a/components/cronet/android/url_request_peer.h
+++ b/components/cronet/android/url_request_adapter.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_
-#define COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_
+#ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_
+#define COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_
#include <jni.h>
@@ -24,31 +24,31 @@ class UploadDataStream;
namespace cronet {
-class URLRequestContextPeer;
+class URLRequestContextAdapter;
// An adapter from the JNI |UrlRequest| object and the Chromium |URLRequest|
// object.
-class URLRequestPeer : public net::URLRequest::Delegate {
+class URLRequestAdapter : public net::URLRequest::Delegate {
public:
// The delegate which is called when the request finishes.
- class URLRequestPeerDelegate
- : public base::RefCountedThreadSafe<URLRequestPeerDelegate> {
+ class URLRequestAdapterDelegate
+ : public base::RefCountedThreadSafe<URLRequestAdapterDelegate> {
public:
- virtual void OnResponseStarted(URLRequestPeer* request) = 0;
- virtual void OnBytesRead(URLRequestPeer* request) = 0;
- virtual void OnRequestFinished(URLRequestPeer* request) = 0;
+ virtual void OnResponseStarted(URLRequestAdapter* request) = 0;
+ virtual void OnBytesRead(URLRequestAdapter* request) = 0;
+ virtual void OnRequestFinished(URLRequestAdapter* request) = 0;
virtual int ReadFromUploadChannel(net::IOBuffer* buf, int buf_length) = 0;
protected:
- friend class base::RefCountedThreadSafe<URLRequestPeerDelegate>;
- virtual ~URLRequestPeerDelegate() {}
+ friend class base::RefCountedThreadSafe<URLRequestAdapterDelegate>;
+ virtual ~URLRequestAdapterDelegate() {}
};
- URLRequestPeer(URLRequestContextPeer* context,
- URLRequestPeerDelegate* delegate,
- GURL url,
- net::RequestPriority priority);
- virtual ~URLRequestPeer();
+ URLRequestAdapter(URLRequestContextAdapter* context,
+ URLRequestAdapterDelegate* delegate,
+ GURL url,
+ net::RequestPriority priority);
+ virtual ~URLRequestAdapter();
// Sets the request method GET, POST etc
void SetMethod(const std::string& method);
@@ -107,7 +107,7 @@ class URLRequestPeer : public net::URLRequest::Delegate {
int bytes_read) OVERRIDE;
private:
- static void OnDestroyRequest(URLRequestPeer* self);
+ static void OnDestroyRequest(URLRequestAdapter* self);
void OnInitiateConnection();
void OnCancelRequest();
@@ -120,8 +120,8 @@ class URLRequestPeer : public net::URLRequest::Delegate {
void Read();
- URLRequestContextPeer* context_;
- scoped_refptr<URLRequestPeerDelegate> delegate_;
+ URLRequestContextAdapter* context_;
+ scoped_refptr<URLRequestAdapterDelegate> delegate_;
GURL url_;
net::RequestPriority priority_;
std::string method_;
@@ -137,9 +137,9 @@ class URLRequestPeer : public net::URLRequest::Delegate {
bool canceled_;
int64 expected_size_;
- DISALLOW_COPY_AND_ASSIGN(URLRequestPeer);
+ DISALLOW_COPY_AND_ASSIGN(URLRequestAdapter);
};
} // namespace cronet
-#endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_PEER_H_
+#endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_ADAPTER_H_
diff --git a/components/cronet/android/url_request_context_peer.cc b/components/cronet/android/url_request_context_adapter.cc
index 84b369e..0feb0f1 100644
--- a/components/cronet/android/url_request_context_peer.cc
+++ b/components/cronet/android/url_request_context_adapter.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/cronet/android/url_request_context_peer.h"
+#include "components/cronet/android/url_request_context_adapter.h"
#include "base/bind.h"
#include "base/file_util.h"
@@ -94,8 +94,8 @@ class BasicNetworkDelegate : public net::NetworkDelegate {
return false;
}
- virtual bool OnCanThrottleRequest(const net::URLRequest& request)
- const OVERRIDE {
+ virtual bool OnCanThrottleRequest(
+ const net::URLRequest& request) const OVERRIDE {
return false;
}
@@ -112,14 +112,14 @@ class BasicNetworkDelegate : public net::NetworkDelegate {
namespace cronet {
-URLRequestContextPeer::URLRequestContextPeer(
- URLRequestContextPeerDelegate* delegate,
+URLRequestContextAdapter::URLRequestContextAdapter(
+ URLRequestContextAdapterDelegate* delegate,
std::string user_agent) {
delegate_ = delegate;
user_agent_ = user_agent;
}
-void URLRequestContextPeer::Initialize(
+void URLRequestContextAdapter::Initialize(
scoped_ptr<URLRequestContextConfig> config) {
network_thread_ = new base::Thread("network");
base::Thread::Options options;
@@ -128,12 +128,12 @@ void URLRequestContextPeer::Initialize(
GetNetworkTaskRunner()->PostTask(
FROM_HERE,
- base::Bind(&URLRequestContextPeer::InitializeURLRequestContext,
+ base::Bind(&URLRequestContextAdapter::InitializeURLRequestContext,
this,
Passed(&config)));
}
-void URLRequestContextPeer::InitializeURLRequestContext(
+void URLRequestContextAdapter::InitializeURLRequestContext(
scoped_ptr<URLRequestContextConfig> config) {
// TODO(mmenke): Add method to have the builder enable SPDY.
net::URLRequestContextBuilder context_builder;
@@ -153,7 +153,7 @@ void URLRequestContextPeer::InitializeURLRequestContext(
delegate_->OnContextInitialized(this);
}
-URLRequestContextPeer::~URLRequestContextPeer() {
+URLRequestContextAdapter::~URLRequestContextAdapter() {
if (net_log_observer_) {
context_->net_log()->RemoveThreadSafeObserver(net_log_observer_.get());
net_log_observer_.reset();
@@ -162,11 +162,12 @@ URLRequestContextPeer::~URLRequestContextPeer() {
// TODO(mef): Ensure that |network_thread_| is destroyed properly.
}
-const std::string& URLRequestContextPeer::GetUserAgent(const GURL& url) const {
+const std::string& URLRequestContextAdapter::GetUserAgent(
+ const GURL& url) const {
return user_agent_;
}
-net::URLRequestContext* URLRequestContextPeer::GetURLRequestContext() {
+net::URLRequestContext* URLRequestContextAdapter::GetURLRequestContext() {
if (!context_) {
LOG(ERROR) << "URLRequestContext is not set up";
}
@@ -174,11 +175,11 @@ net::URLRequestContext* URLRequestContextPeer::GetURLRequestContext() {
}
scoped_refptr<base::SingleThreadTaskRunner>
-URLRequestContextPeer::GetNetworkTaskRunner() const {
+URLRequestContextAdapter::GetNetworkTaskRunner() const {
return network_thread_->message_loop_proxy();
}
-void URLRequestContextPeer::StartNetLogToFile(const std::string& file_name) {
+void URLRequestContextAdapter::StartNetLogToFile(const std::string& file_name) {
// Do nothing if already logging to a file.
if (net_log_logger_)
return;
@@ -193,7 +194,7 @@ void URLRequestContextPeer::StartNetLogToFile(const std::string& file_name) {
net_log_logger_->StartObserving(context_->net_log());
}
-void URLRequestContextPeer::StopNetLog() {
+void URLRequestContextAdapter::StopNetLog() {
if (net_log_logger_) {
net_log_logger_->StopObserving();
net_log_logger_.reset();
@@ -202,8 +203,7 @@ void URLRequestContextPeer::StopNetLog() {
void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) {
VLOG(2) << "Net log entry: type=" << entry.type()
- << ", source=" << entry.source().type
- << ", phase=" << entry.phase();
+ << ", source=" << entry.source().type << ", phase=" << entry.phase();
}
} // namespace cronet
diff --git a/components/cronet/android/url_request_context_peer.h b/components/cronet/android/url_request_context_adapter.h
index 572e650..ef4fcd6 100644
--- a/components/cronet/android/url_request_context_peer.h
+++ b/components/cronet/android/url_request_context_adapter.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
-#define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
+#ifndef COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_
+#define COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_
#include <string>
@@ -39,21 +39,21 @@ class NetLogObserver : public net::NetLog::ThreadSafeObserver {
};
// Fully configured |URLRequestContext|.
-class URLRequestContextPeer : public net::URLRequestContextGetter {
+class URLRequestContextAdapter : public net::URLRequestContextGetter {
public:
- class URLRequestContextPeerDelegate
- : public base::RefCountedThreadSafe<URLRequestContextPeerDelegate> {
+ class URLRequestContextAdapterDelegate
+ : public base::RefCountedThreadSafe<URLRequestContextAdapterDelegate> {
public:
- virtual void OnContextInitialized(URLRequestContextPeer* context) = 0;
+ virtual void OnContextInitialized(URLRequestContextAdapter* context) = 0;
protected:
- friend class base::RefCountedThreadSafe<URLRequestContextPeerDelegate>;
+ friend class base::RefCountedThreadSafe<URLRequestContextAdapterDelegate>;
- virtual ~URLRequestContextPeerDelegate() {}
+ virtual ~URLRequestContextAdapterDelegate() {}
};
- URLRequestContextPeer(URLRequestContextPeerDelegate* delegate,
- std::string user_agent);
+ URLRequestContextAdapter(URLRequestContextAdapterDelegate* delegate,
+ std::string user_agent);
void Initialize(scoped_ptr<URLRequestContextConfig> config);
const std::string& GetUserAgent(const GURL& url) const;
@@ -67,7 +67,7 @@ class URLRequestContextPeer : public net::URLRequestContextGetter {
void StopNetLog();
private:
- scoped_refptr<URLRequestContextPeerDelegate> delegate_;
+ scoped_refptr<URLRequestContextAdapterDelegate> delegate_;
scoped_ptr<net::URLRequestContext> context_;
std::string user_agent_;
base::Thread* network_thread_;
@@ -75,14 +75,14 @@ class URLRequestContextPeer : public net::URLRequestContextGetter {
scoped_ptr<NetLogObserver> net_log_observer_;
scoped_ptr<net::NetLogLogger> net_log_logger_;
- virtual ~URLRequestContextPeer();
+ virtual ~URLRequestContextAdapter();
// Initializes |context_| on the IO thread.
void InitializeURLRequestContext(scoped_ptr<URLRequestContextConfig> config);
- DISALLOW_COPY_AND_ASSIGN(URLRequestContextPeer);
+ DISALLOW_COPY_AND_ASSIGN(URLRequestContextAdapter);
};
} // namespace cronet
-#endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_PEER_H_
+#endif // COMPONENTS_CRONET_ANDROID_URL_REQUEST_CONTEXT_ADAPTER_H_
diff --git a/components/cronet/android/wrapped_channel_upload_element_reader.cc b/components/cronet/android/wrapped_channel_upload_element_reader.cc
index db6fc78..3027cba 100644
--- a/components/cronet/android/wrapped_channel_upload_element_reader.cc
+++ b/components/cronet/android/wrapped_channel_upload_element_reader.cc
@@ -12,7 +12,7 @@
namespace cronet {
WrappedChannelElementReader::WrappedChannelElementReader(
- scoped_refptr<URLRequestPeer::URLRequestPeerDelegate> delegate,
+ scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate,
uint64 length)
: length_(length), offset_(0), delegate_(delegate) {
}
diff --git a/components/cronet/android/wrapped_channel_upload_element_reader.h b/components/cronet/android/wrapped_channel_upload_element_reader.h
index c438f6f..251a3ec 100644
--- a/components/cronet/android/wrapped_channel_upload_element_reader.h
+++ b/components/cronet/android/wrapped_channel_upload_element_reader.h
@@ -7,7 +7,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
-#include "components/cronet/android/url_request_peer.h"
+#include "components/cronet/android/url_request_adapter.h"
#include "net/base/completion_callback.h"
#include "net/base/upload_element_reader.h"
@@ -24,7 +24,7 @@ namespace cronet {
class WrappedChannelElementReader : public net::UploadElementReader {
public:
WrappedChannelElementReader(
- scoped_refptr<URLRequestPeer::URLRequestPeerDelegate> delegate,
+ scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate,
uint64 length);
virtual ~WrappedChannelElementReader();
@@ -40,7 +40,7 @@ class WrappedChannelElementReader : public net::UploadElementReader {
private:
const uint64 length_;
uint64 offset_;
- scoped_refptr<URLRequestPeer::URLRequestPeerDelegate> delegate_;
+ scoped_refptr<URLRequestAdapter::URLRequestAdapterDelegate> delegate_;
DISALLOW_COPY_AND_ASSIGN(WrappedChannelElementReader);
};