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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/urlconnection/CronetHttpURLConnection.java

Issue 1984723002: Support setReadTimeout in CronetHttpURLConnection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | components/cronet/android/java/src/org/chromium/net/urlconnection/MessageLoop.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.net.urlconnection; 5 package org.chromium.net.urlconnection;
6 6
7 import android.util.Pair; 7 import android.util.Pair;
8 8
9 import org.chromium.base.Log; 9 import org.chromium.base.Log;
10 import org.chromium.net.CronetEngine; 10 import org.chromium.net.CronetEngine;
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 /** 399 /**
400 * Used by {@link CronetInputStream} to get more data from the network 400 * Used by {@link CronetInputStream} to get more data from the network
401 * stack. This should only be called after the request has started. Note 401 * stack. This should only be called after the request has started. Note
402 * that this call might block if there isn't any more data to be read. 402 * that this call might block if there isn't any more data to be read.
403 * Since byteBuffer is passed to the UrlRequest, it must be a direct 403 * Since byteBuffer is passed to the UrlRequest, it must be a direct
404 * ByteBuffer. 404 * ByteBuffer.
405 */ 405 */
406 void getMoreData(ByteBuffer byteBuffer) throws IOException { 406 void getMoreData(ByteBuffer byteBuffer) throws IOException {
407 mRequest.read(byteBuffer); 407 mRequest.read(byteBuffer);
408 mMessageLoop.loop(); 408 mMessageLoop.loop(getReadTimeout());
jdcormie 2016/05/17 17:48:34 MessageLoop.loop(int timeout) appears to pull and
xunjieli 2016/05/17 19:43:07 Talked to Andrei. MessageLoop is our internal impl
409 } 409 }
410 410
411 /** 411 /**
412 * Returns the index of request header in {@link #mRequestHeaders} or 412 * Returns the index of request header in {@link #mRequestHeaders} or
413 * -1 if not found. 413 * -1 if not found.
414 */ 414 */
415 private int findRequestProperty(String key) { 415 private int findRequestProperty(String key) {
416 for (int i = 0; i < mRequestHeaders.size(); i++) { 416 for (int i = 0; i < mRequestHeaders.size(); i++) {
417 Pair<String, String> entry = mRequestHeaders.get(i); 417 Pair<String, String> entry = mRequestHeaders.get(i);
418 if (entry.first.equalsIgnoreCase(key)) { 418 if (entry.first.equalsIgnoreCase(key)) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 if (mOutputStream != null) { 509 if (mOutputStream != null) {
510 mOutputStream.checkReceivedEnoughContent(); 510 mOutputStream.checkReceivedEnoughContent();
511 if (isChunkedUpload()) { 511 if (isChunkedUpload()) {
512 // Write last chunk. 512 // Write last chunk.
513 mOutputStream.close(); 513 mOutputStream.close();
514 } 514 }
515 } 515 }
516 if (!mHasResponse) { 516 if (!mHasResponse) {
517 startRequest(); 517 startRequest();
518 // Blocks until onResponseStarted or onFailed is called. 518 // Blocks until onResponseStarted or onFailed is called.
519 mMessageLoop.loop(); 519 mMessageLoop.loop(getConnectTimeout());
520 mHasResponse = true; 520 mHasResponse = true;
521 } 521 }
522 checkHasResponse(); 522 checkHasResponse();
523 } 523 }
524 524
525 /** 525 /**
526 * Checks whether response headers are received, and throws an exception if 526 * Checks whether response headers are received, and throws an exception if
527 * an exception occurred before headers received. This method should only be 527 * an exception occurred before headers received. This method should only be
528 * called after onResponseStarted or onFailed. 528 * called after onResponseStarted or onFailed.
529 */ 529 */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // Strips Content-Encoding response header. See crbug.com/592700. 588 // Strips Content-Encoding response header. See crbug.com/592700.
589 if (!entry.getKey().equalsIgnoreCase("Content-Encoding")) { 589 if (!entry.getKey().equalsIgnoreCase("Content-Encoding")) {
590 mResponseHeadersList.add( 590 mResponseHeadersList.add(
591 new AbstractMap.SimpleImmutableEntry<String, String>(ent ry)); 591 new AbstractMap.SimpleImmutableEntry<String, String>(ent ry));
592 } 592 }
593 } 593 }
594 mResponseHeadersList = Collections.unmodifiableList(mResponseHeadersList ); 594 mResponseHeadersList = Collections.unmodifiableList(mResponseHeadersList );
595 return mResponseHeadersList; 595 return mResponseHeadersList;
596 } 596 }
597 } 597 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/java/src/org/chromium/net/urlconnection/MessageLoop.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698