Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java

Issue 1492583002: Add HttpUrlConnection backed implementation of CronetEngine. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enabled user agent test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
diff --git a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
index b20f810d38db52a1c8b3a339b33f36ba29880659..d5692111472ff7eb7ab9d1397cc3a7e0fce5108c 100644
--- a/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
+++ b/components/cronet/android/java/src/org/chromium/net/CronetUrlRequest.java
@@ -256,6 +256,7 @@ final class CronetUrlRequest implements UrlRequest {
throw new IllegalArgumentException(
"ByteBuffer is already full.");
}
+ Preconditions.checkDirect(buffer);
if (!mWaitingOnRead) {
throw new IllegalStateException("Unexpected read attempt.");
@@ -276,21 +277,16 @@ final class CronetUrlRequest implements UrlRequest {
// Still waiting on read. This is just to have consistent
// behavior with the other error cases.
mWaitingOnRead = true;
- // Since accessing byteBuffer's memory failed, it's presumably
- // not a direct ByteBuffer.
- throw new IllegalArgumentException(
- "byteBuffer must be a direct ByteBuffer.");
+ throw new IllegalArgumentException("Unable to call native read");
}
}
}
@Override
public void readNew(ByteBuffer buffer) {
+ Preconditions.checkHasRemaining(buffer);
+ Preconditions.checkDirect(buffer);
synchronized (mUrlRequestAdapterLock) {
- if (!buffer.hasRemaining()) {
- throw new IllegalArgumentException("ByteBuffer is already full.");
- }
-
if (!mWaitingOnRead) {
throw new IllegalStateException("Unexpected read attempt.");
}
@@ -305,9 +301,7 @@ final class CronetUrlRequest implements UrlRequest {
// Still waiting on read. This is just to have consistent
// behavior with the other error cases.
mWaitingOnRead = true;
- // Since accessing byteBuffer's memory failed, it's presumably
- // not a direct ByteBuffer.
- throw new IllegalArgumentException("byteBuffer must be a direct ByteBuffer.");
+ throw new IllegalArgumentException("Unable to call native read");
}
}
}

Powered by Google App Engine
This is Rietveld 408576698