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 @@ ...@@ -10,12 +10,10 @@
# TODO(mef) remove unnecessary classes from base, so we don't have to preserve # TODO(mef) remove unnecessary classes from base, so we don't have to preserve
# their methods # their methods
-keepclasseswithmembers class org.chromium.** { -keep class org.chromium.** {
native <methods>; native <methods>;
} }
-dontnote org.chromium.net.AndroidKeyStore
# Needed so that multiple optimization passes will detect annotations # Needed so that multiple optimization passes will detect annotations
-keepattributes *Annotation* -keepattributes *Annotation*
...@@ -24,4 +22,12 @@ ...@@ -24,4 +22,12 @@
-keep @org.chromium.net.UsedBy* class * -keep @org.chromium.net.UsedBy* class *
-keepclassmembers class * { -keepclassmembers class * {
@org.chromium.net.UsedBy* *; @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; ...@@ -14,7 +14,7 @@ import org.chromium.net.HttpUrlRequestFactoryConfig;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* Tests for {@link ChunkedWritableByteChannel} * Tests for {@link HttpUrlRequestFactory}
*/ */
public class HttpUrlRequestFactoryTest extends InstrumentationTestCase { public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
@SmallTest @SmallTest
...@@ -24,8 +24,8 @@ public class HttpUrlRequestFactoryTest extends InstrumentationTestCase { ...@@ -24,8 +24,8 @@ public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory( HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
getInstrumentation().getContext(), config); getInstrumentation().getContext(), config);
assertNotNull("Factory should be created", factory); assertNotNull("Factory should be created", factory);
assertTrue("Factory should be Chromium/n.n.n.n/r", assertTrue("Factory should be Chromium/n.n.n.n@r",
Pattern.matches("Chromium/\\d+\\.\\d+\\.\\d+\\.\\d+@\\d+", Pattern.matches("Chromium/\\d+\\.\\d+\\.\\d+\\.\\d+@\\w+",
factory.getName())); factory.getName()));
} }
...@@ -39,7 +39,8 @@ public class HttpUrlRequestFactoryTest extends InstrumentationTestCase { ...@@ -39,7 +39,8 @@ public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
getInstrumentation().getContext(), config); getInstrumentation().getContext(), config);
assertNotNull("Factory should be created", factory); assertNotNull("Factory should be created", factory);
assertTrue("Factory should be HttpUrlConnection/n.n.n.n@r", 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())); factory.getName()));
} }
} }
...@@ -25,7 +25,6 @@ URLRequestAdapter::URLRequestAdapter(URLRequestContextAdapter* context, ...@@ -25,7 +25,6 @@ URLRequestAdapter::URLRequestAdapter(URLRequestContextAdapter* context,
GURL url, GURL url,
net::RequestPriority priority) net::RequestPriority priority)
: method_("GET"), : method_("GET"),
url_request_(NULL),
read_buffer_(new net::GrowableIOBuffer()), read_buffer_(new net::GrowableIOBuffer()),
bytes_read_(0), bytes_read_(0),
total_bytes_read_(0), total_bytes_read_(0),
...@@ -121,8 +120,8 @@ void URLRequestAdapter::OnInitiateConnection() { ...@@ -121,8 +120,8 @@ void URLRequestAdapter::OnInitiateConnection() {
VLOG(1) << "Starting chromium request: " VLOG(1) << "Starting chromium request: "
<< url_.possibly_invalid_spec().c_str() << url_.possibly_invalid_spec().c_str()
<< " priority: " << RequestPriorityToString(priority_); << " priority: " << RequestPriorityToString(priority_);
url_request_ = new net::URLRequest( url_request_ = context_->GetURLRequestContext()->CreateRequest(
url_, net::DEFAULT_PRIORITY, this, context_->GetURLRequestContext()); url_, net::DEFAULT_PRIORITY, this, NULL);
url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE | url_request_->SetLoadFlags(net::LOAD_DISABLE_CACHE |
net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES |
net::LOAD_DO_NOT_SEND_COOKIES); net::LOAD_DO_NOT_SEND_COOKIES);
...@@ -281,10 +280,7 @@ void URLRequestAdapter::OnRequestCanceled() { ...@@ -281,10 +280,7 @@ void URLRequestAdapter::OnRequestCanceled() {
void URLRequestAdapter::OnRequestCompleted() { void URLRequestAdapter::OnRequestCompleted() {
VLOG(1) << "Completed: " << url_.possibly_invalid_spec(); VLOG(1) << "Completed: " << url_.possibly_invalid_spec();
if (url_request_ != NULL) { url_request_.reset();
delete url_request_;
url_request_ = NULL;
}
delegate_->OnBytesRead(this); delegate_->OnBytesRead(this);
delegate_->OnRequestFinished(this); delegate_->OnRequestFinished(this);
......
...@@ -135,7 +135,7 @@ class URLRequestAdapter : public net::URLRequest::Delegate { ...@@ -135,7 +135,7 @@ class URLRequestAdapter : public net::URLRequest::Delegate {
net::RequestPriority priority_; net::RequestPriority priority_;
std::string method_; std::string method_;
net::HttpRequestHeaders headers_; net::HttpRequestHeaders headers_;
net::URLRequest* url_request_; scoped_ptr<net::URLRequest> url_request_;
scoped_ptr<net::UploadDataStream> upload_data_stream_; scoped_ptr<net::UploadDataStream> upload_data_stream_;
scoped_refptr<net::GrowableIOBuffer> read_buffer_; scoped_refptr<net::GrowableIOBuffer> read_buffer_;
int bytes_read_; 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