| 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.urlconnection; | 5 package org.chromium.net.urlconnection; |
| 6 | 6 |
| 7 import org.chromium.net.UploadDataProvider; | 7 import org.chromium.net.UploadDataProvider; |
| 8 | 8 |
| 9 import java.io.IOException; | 9 import java.io.IOException; |
| 10 import java.io.OutputStream; | 10 import java.io.OutputStream; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 void setRequestCompleted(IOException exception) { | 47 void setRequestCompleted(IOException exception) { |
| 48 mException = exception; | 48 mException = exception; |
| 49 mRequestCompleted = true; | 49 mRequestCompleted = true; |
| 50 } | 50 } |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Throws an IOException if the stream is closed or the request is done. | 53 * Throws an IOException if the stream is closed or the request is done. |
| 54 */ | 54 */ |
| 55 protected void checkNotClosed() throws IOException { | 55 protected void checkNotClosed() throws IOException { |
| 56 if (mRequestCompleted) { | 56 if (mRequestCompleted) { |
| 57 if (mException != null) { | 57 checkNoException(); |
| 58 throw mException; | |
| 59 } | |
| 60 throw new IOException("Writing after request completed."); | 58 throw new IOException("Writing after request completed."); |
| 61 } | 59 } |
| 62 if (mClosed) { | 60 if (mClosed) { |
| 63 throw new IOException("Stream has been closed."); | 61 throw new IOException("Stream has been closed."); |
| 64 } | 62 } |
| 65 } | 63 } |
| 64 |
| 65 /** |
| 66 * Throws the same IOException that the request is failed with. If there |
| 67 * is no exception reported, this method is no-op. |
| 68 */ |
| 69 protected void checkNoException() throws IOException { |
| 70 if (mException != null) { |
| 71 throw mException; |
| 72 } |
| 73 } |
| 66 } | 74 } |
| OLD | NEW |