| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; |
| 7 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 8 import android.net.TrafficStats; | 9 import android.net.TrafficStats; |
| 9 import android.os.Build; | 10 import android.os.Build; |
| 10 import android.util.Log; | 11 import android.util.Log; |
| 11 | 12 |
| 12 import java.io.Closeable; | 13 import java.io.Closeable; |
| 13 import java.io.IOException; | 14 import java.io.IOException; |
| 14 import java.io.OutputStream; | 15 import java.io.OutputStream; |
| 15 import java.net.HttpURLConnection; | 16 import java.net.HttpURLConnection; |
| 16 import java.net.URI; | 17 import java.net.URI; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 enterUploadErrorState(e); | 281 enterUploadErrorState(e); |
| 281 } | 282 } |
| 282 } | 283 } |
| 283 }; | 284 }; |
| 284 this.mExecutor = executor; | 285 this.mExecutor = executor; |
| 285 this.mUrlConnection = urlConnection; | 286 this.mUrlConnection = urlConnection; |
| 286 this.mUploadProvider = provider; | 287 this.mUploadProvider = provider; |
| 287 } | 288 } |
| 288 | 289 |
| 289 @Override | 290 @Override |
| 291 @SuppressLint("DefaultLocale") |
| 290 public void onReadSucceeded(final boolean finalChunk) { | 292 public void onReadSucceeded(final boolean finalChunk) { |
| 291 if (!mSinkState.compareAndSet(SinkState.AWAITING_READ_RESULT, SinkSt
ate.UPLOADING)) { | 293 if (!mSinkState.compareAndSet(SinkState.AWAITING_READ_RESULT, SinkSt
ate.UPLOADING)) { |
| 292 throw new IllegalStateException( | 294 throw new IllegalStateException( |
| 293 "Not expecting a read result, expecting: " + mSinkState.
get()); | 295 "Not expecting a read result, expecting: " + mSinkState.
get()); |
| 294 } | 296 } |
| 295 mExecutor.execute(errorSetting(new CheckedRunnable() { | 297 mExecutor.execute(errorSetting(new CheckedRunnable() { |
| 296 @Override | 298 @Override |
| 297 public void run() throws Exception { | 299 public void run() throws Exception { |
| 298 mBuffer.flip(); | 300 mBuffer.flip(); |
| 299 if (mTotalBytes != -1 && mTotalBytes - mWrittenBytes < mBuff
er.remaining()) { | 301 if (mTotalBytes != -1 && mTotalBytes - mWrittenBytes < mBuff
er.remaining()) { |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 // Can't throw directly from here, since the delegate execut
or could catch this | 959 // Can't throw directly from here, since the delegate execut
or could catch this |
| 958 // exception. | 960 // exception. |
| 959 mExecutedInline = new InlineExecutionProhibitedException(); | 961 mExecutedInline = new InlineExecutionProhibitedException(); |
| 960 return; | 962 return; |
| 961 } | 963 } |
| 962 mCommand.run(); | 964 mCommand.run(); |
| 963 } | 965 } |
| 964 } | 966 } |
| 965 } | 967 } |
| 966 } | 968 } |
| OLD | NEW |