Commit ac2715c6 authored by mef's avatar mef Committed by Commit bot

Fix Cronet compilation and test errors.

- Use UrlRequestContext.CreateRequest.
- Expect GIT revision in HttpUrlRequestFactoryTest.
- Prevent getAllHeaders from being removed by proguard.

BUG=390267

Review URL: https://codereview.chromium.org/500193002

Cr-Commit-Position: refs/heads/master@{#291912}
parent df86d3ab
......@@ -10,12 +10,10 @@
# TODO(mef) remove unnecessary classes from base, so we don't have to preserve
# their methods
-keepclasseswithmembers class org.chromium.** {
-keep class org.chromium.** {
native <methods>;
}
-dontnote org.chromium.net.AndroidKeyStore
# Needed so that multiple optimization passes will detect annotations
-keepattributes *Annotation*
......@@ -24,4 +22,12 @@
-keep @org.chromium.net.UsedBy* class *
-keepclassmembers class * {
@org.chromium.net.UsedBy* *;
}
\ No newline at end of file
}
# Suppress unnecessary warnings.
-dontnote org.chromium.net.AndroidKeyStore
# Objects of this type are passed around by native code, but the class
# is never used directly by native code. Since the class is not loaded, it does
# not need to be preserved as an entry point.
-dontnote org.chromium.net.UrlRequest$ResponseHeadersMap
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.cronet_sample_apk;
import android.content.Context;
import android.os.PowerManager;
import android.test.suitebuilder.annotation.Smoke;
import org.chromium.base.test.util.Feature;
/**
* Test that verifies preconditions for tests to run.
*/
public class CronetSamplePreconditionsTest extends CronetSampleTestBase {
@Smoke
@Feature({"TestInfrastructure"})
public void testScreenIsOn() throws Exception {
PowerManager pm = (PowerManager)getInstrumentation().getContext()
.getSystemService(Context.POWER_SERVICE);
assertTrue("Many tests will fail if the screen is not on.",
pm.isScreenOn());
}
}
......@@ -14,7 +14,7 @@ import org.chromium.net.HttpUrlRequestFactoryConfig;
import java.util.regex.Pattern;
/**
* Tests for {@link ChunkedWritableByteChannel}
* Tests for {@link HttpUrlRequestFactory}
*/
public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
@SmallTest
......@@ -24,8 +24,8 @@ public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
getInstrumentation().getContext(), config);
assertNotNull("Factory should be created", factory);
assertTrue("Factory should be Chromium/n.n.n.n/r",
Pattern.matches("Chromium/\\d+\\.\\d+\\.\\d+\\.\\d+@\\d+",
assertTrue("Factory should be Chromium/n.n.n.n@r",
Pattern.matches("Chromium/\\d+\\.\\d+\\.\\d+\\.\\d+@\\w+",
factory.getName()));
}
......@@ -39,7 +39,8 @@ public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
getInstrumentation().getContext(), config);
assertNotNull("Factory should be created", factory);
assertTrue("Factory should be HttpUrlConnection/n.n.n.n@r",
Pattern.matches("HttpUrlConnection/\\d+\\.\\d+\\.\\d+\\.\\d+@\\d+",
Pattern.matches(
"HttpUrlConnection/\\d+\\.\\d+\\.\\d+\\.\\d+@\\w+",
factory.getName()));
}
}
......@@ -25,7 +25,6 @@ URLRequestAdapter::URLRequestAdapter(URLRequestContextAdapter* context,
GURL url,
net::RequestPriority priority)
: method_("GET"),
url_request_(NULL),
read_buffer_(new net::GrowableIOBuffer()),
bytes_read_(0),
total_bytes_read_(0),
......@@ -121,8 +120,8 @@ void URLRequestAdapter::OnInitiateConnection() {
VLOG(1) << "Starting chromium request: "
<< url_.possibly_invalid_spec().c_str()
<< " priority: " << RequestPriorityToString(priority_);
url_request_ = new net::URLRequest(
url_, net::DEFAULT_PRIORITY, this, context_->GetURLRequestContext());
url_request_ = context_->GetURLRequestContext()->CreateRequest(
url_, net::DEFAULT_PRIORITY, this, NULL);
url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
net::LOAD_DO_NOT_SAVE_COOKIES |
net::LOAD_DO_NOT_SEND_COOKIES);
......@@ -281,10 +280,7 @@ void URLRequestAdapter::OnRequestCanceled() {
void URLRequestAdapter::OnRequestCompleted() {
VLOG(1) << "Completed: " << url_.possibly_invalid_spec();
if (url_request_ != NULL) {
delete url_request_;
url_request_ = NULL;
}
url_request_.reset();
delegate_->OnBytesRead(this);
delegate_->OnRequestFinished(this);
......
......@@ -135,7 +135,7 @@ class URLRequestAdapter : public net::URLRequest::Delegate {
net::RequestPriority priority_;
std::string method_;
net::HttpRequestHeaders headers_;
net::URLRequest* url_request_;
scoped_ptr<net::URLRequest> url_request_;
scoped_ptr<net::UploadDataStream> upload_data_stream_;
scoped_refptr<net::GrowableIOBuffer> read_buffer_;
int bytes_read_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment