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 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_UPLOAD_DATA_STREAM_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_UPLOAD_DATA_STREAM_H_ |
6 #define COMPONENTS_CRONET_ANDROID_CRONET_UPLOAD_DATA_STREAM_H_ | 6 #define COMPONENTS_CRONET_ANDROID_CRONET_UPLOAD_DATA_STREAM_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include <stdint.h> |
| 9 |
9 #include "base/macros.h" | 10 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 #include "net/base/upload_data_stream.h" | 13 #include "net/base/upload_data_stream.h" |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 class IOBuffer; | 16 class IOBuffer; |
16 } // namespace net | 17 } // namespace net |
17 | 18 |
18 namespace cronet { | 19 namespace cronet { |
(...skipping 29 matching lines...) Expand all Loading... |
48 virtual void OnUploadDataStreamDestroyed() = 0; | 49 virtual void OnUploadDataStreamDestroyed() = 0; |
49 | 50 |
50 protected: | 51 protected: |
51 Delegate() {} | 52 Delegate() {} |
52 virtual ~Delegate() {} | 53 virtual ~Delegate() {} |
53 | 54 |
54 private: | 55 private: |
55 DISALLOW_COPY_AND_ASSIGN(Delegate); | 56 DISALLOW_COPY_AND_ASSIGN(Delegate); |
56 }; | 57 }; |
57 | 58 |
58 CronetUploadDataStream(Delegate* delegate, int64 size); | 59 CronetUploadDataStream(Delegate* delegate, int64_t size); |
59 ~CronetUploadDataStream() override; | 60 ~CronetUploadDataStream() override; |
60 | 61 |
61 // Failure is handled at the Java layer. These two success callbacks are | 62 // Failure is handled at the Java layer. These two success callbacks are |
62 // invoked by Java UploadDataSink upon completion of the operation. | 63 // invoked by Java UploadDataSink upon completion of the operation. |
63 void OnReadSuccess(int bytes_read, bool final_chunk); | 64 void OnReadSuccess(int bytes_read, bool final_chunk); |
64 void OnRewindSuccess(); | 65 void OnRewindSuccess(); |
65 | 66 |
66 private: | 67 private: |
67 // net::UploadDataStream implementation: | 68 // net::UploadDataStream implementation: |
68 int InitInternal() override; | 69 int InitInternal() override; |
69 int ReadInternal(net::IOBuffer* buf, int buf_len) override; | 70 int ReadInternal(net::IOBuffer* buf, int buf_len) override; |
70 void ResetInternal() override; | 71 void ResetInternal() override; |
71 | 72 |
72 // Starts rewinding the stream. Only called when not already at the front of | 73 // Starts rewinding the stream. Only called when not already at the front of |
73 // the stream, and no operation is pending. Completes asynchronously. | 74 // the stream, and no operation is pending. Completes asynchronously. |
74 void StartRewind(); | 75 void StartRewind(); |
75 | 76 |
76 // Size of the upload. -1 if chunked. | 77 // Size of the upload. -1 if chunked. |
77 const int64 size_; | 78 const int64_t size_; |
78 | 79 |
79 // True if ReadInternal has been called, the read hasn't completed, and there | 80 // True if ReadInternal has been called, the read hasn't completed, and there |
80 // hasn't been a ResetInternal call yet. | 81 // hasn't been a ResetInternal call yet. |
81 bool waiting_on_read_; | 82 bool waiting_on_read_; |
82 // True if there's a read operation in progress. This will always be true | 83 // True if there's a read operation in progress. This will always be true |
83 // when |waiting_on_read_| is true. This will only be set to false once it | 84 // when |waiting_on_read_| is true. This will only be set to false once it |
84 // completes, even though ResetInternal may have been called since the read | 85 // completes, even though ResetInternal may have been called since the read |
85 // started. | 86 // started. |
86 bool read_in_progress_; | 87 bool read_in_progress_; |
87 | 88 |
(...skipping 14 matching lines...) Expand all Loading... |
102 | 103 |
103 // Vends pointers on the network thread, though created on a Java thread. | 104 // Vends pointers on the network thread, though created on a Java thread. |
104 base::WeakPtrFactory<CronetUploadDataStream> weak_factory_; | 105 base::WeakPtrFactory<CronetUploadDataStream> weak_factory_; |
105 | 106 |
106 DISALLOW_COPY_AND_ASSIGN(CronetUploadDataStream); | 107 DISALLOW_COPY_AND_ASSIGN(CronetUploadDataStream); |
107 }; | 108 }; |
108 | 109 |
109 } // namespace cronet | 110 } // namespace cronet |
110 | 111 |
111 #endif // COMPONENTS_CRONET_ANDROID_CRONET_UPLOAD_DATA_STREAM_H_ | 112 #endif // COMPONENTS_CRONET_ANDROID_CRONET_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |