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.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.net.TrafficStats; | 8 import android.net.TrafficStats; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.util.Log; | 10 import android.util.Log; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 public void onReadError(Exception exception) { | 319 public void onReadError(Exception exception) { |
320 enterUploadErrorState(exception); | 320 enterUploadErrorState(exception); |
321 } | 321 } |
322 | 322 |
323 @Override | 323 @Override |
324 public void onRewindError(Exception exception) { | 324 public void onRewindError(Exception exception) { |
325 enterUploadErrorState(exception); | 325 enterUploadErrorState(exception); |
326 } | 326 } |
327 | 327 |
328 void startRead() { | 328 void startRead() { |
329 mUserExecutor.execute(uploadErrorSetting(new CheckedRunnable() { | 329 mExecutor.execute(errorSetting(State.STARTED, new CheckedRunnable()
{ |
330 @Override | 330 @Override |
331 public void run() throws Exception { | 331 public void run() throws Exception { |
332 if (mOutputChannel == null) { | 332 if (mOutputChannel == null) { |
333 mAdditionalStatusDetails = Status.CONNECTING; | 333 mAdditionalStatusDetails = Status.CONNECTING; |
334 mUrlConnection.connect(); | 334 mUrlConnection.connect(); |
335 mAdditionalStatusDetails = Status.SENDING_REQUEST; | 335 mAdditionalStatusDetails = Status.SENDING_REQUEST; |
336 mOutputChannel = Channels.newChannel(mUrlConnection.getO
utputStream()); | 336 mOutputChannel = Channels.newChannel(mUrlConnection.getO
utputStream()); |
337 } | 337 } |
338 mSinkState.set(SinkState.AWAITING_READ_RESULT); | 338 mSinkState.set(SinkState.AWAITING_READ_RESULT); |
339 mUploadProvider.read(OutputStreamDataSink.this, mBuffer); | 339 mUserExecutor.execute(uploadErrorSetting(new CheckedRunnable
() { |
| 340 @Override |
| 341 public void run() throws Exception { |
| 342 mUploadProvider.read(OutputStreamDataSink.this, mBuf
fer); |
| 343 } |
| 344 })); |
340 } | 345 } |
341 })); | 346 })); |
342 } | 347 } |
343 | 348 |
344 void finish() throws IOException { | 349 void finish() throws IOException { |
345 if (mOutputChannel != null) { | 350 if (mOutputChannel != null) { |
346 mOutputChannel.close(); | 351 mOutputChannel.close(); |
347 } | 352 } |
348 fireGetHeaders(); | 353 fireGetHeaders(); |
349 } | 354 } |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 if (closeable == null) { | 841 if (closeable == null) { |
837 return; | 842 return; |
838 } | 843 } |
839 try { | 844 try { |
840 closeable.close(); | 845 closeable.close(); |
841 } catch (IOException e) { | 846 } catch (IOException e) { |
842 e.printStackTrace(); | 847 e.printStackTrace(); |
843 } | 848 } |
844 } | 849 } |
845 } | 850 } |
OLD | NEW |