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

Side by Side Diff: components/cronet/android/wrapped_channel_upload_element_reader.h

Issue 442803002: Remove explicit JNI references by adding UrlRequest.readFromUploadChannel callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove spurious space. Created 6 years, 4 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 | Annotate | Revision Log
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 #ifndef COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ 5 #ifndef COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_
6 #define COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ 6 #define COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_
7 7
8 #include <jni.h>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "components/cronet/android/url_request_peer.h"
12 #include "net/base/completion_callback.h" 11 #include "net/base/completion_callback.h"
13 #include "net/base/upload_element_reader.h" 12 #include "net/base/upload_element_reader.h"
14 13
15 namespace net { 14 namespace net {
16 class IOBuffer; 15 class IOBuffer;
17 } // namespace net 16 } // namespace net
18 17
19 namespace cronet { 18 namespace cronet {
20 19
21 bool WrappedChannelRegisterJni(JNIEnv* env);
22
23 // An UploadElementReader implementation for 20 // An UploadElementReader implementation for
24 // java.nio.channels.ReadableByteChannel. 21 // java.nio.channels.ReadableByteChannel.
25 // |channel_| should outlive this class because this class does not take the 22 // |channel_| should outlive this class because this class does not take the
26 // ownership of the data. 23 // ownership of the data.
27 class WrappedChannelElementReader : public net::UploadElementReader { 24 class WrappedChannelElementReader : public net::UploadElementReader {
28 public: 25 public:
29 WrappedChannelElementReader(JNIEnv* env, jobject channel, uint64 length); 26 WrappedChannelElementReader(
27 scoped_refptr<URLRequestPeer::URLRequestPeerDelegate> delegate,
28 uint64 length);
30 virtual ~WrappedChannelElementReader(); 29 virtual ~WrappedChannelElementReader();
31 30
32 // UploadElementReader overrides: 31 // UploadElementReader overrides:
33 virtual int Init(const net::CompletionCallback& callback) OVERRIDE; 32 virtual int Init(const net::CompletionCallback& callback) OVERRIDE;
34 virtual uint64 GetContentLength() const OVERRIDE; 33 virtual uint64 GetContentLength() const OVERRIDE;
35 virtual uint64 BytesRemaining() const OVERRIDE; 34 virtual uint64 BytesRemaining() const OVERRIDE;
36 virtual bool IsInMemory() const OVERRIDE; 35 virtual bool IsInMemory() const OVERRIDE;
37 virtual int Read(net::IOBuffer* buf, 36 virtual int Read(net::IOBuffer* buf,
38 int buf_length, 37 int buf_length,
39 const net::CompletionCallback& callback) OVERRIDE; 38 const net::CompletionCallback& callback) OVERRIDE;
40 39
41 private: 40 private:
42 const uint64 length_; 41 const uint64 length_;
43 uint64 offset_; 42 uint64 offset_;
44 jobject channel_; 43 scoped_refptr<URLRequestPeer::URLRequestPeerDelegate> delegate_;
45 44
46 DISALLOW_COPY_AND_ASSIGN(WrappedChannelElementReader); 45 DISALLOW_COPY_AND_ASSIGN(WrappedChannelElementReader);
47 }; 46 };
48 47
49 } // namespace cronet 48 } // namespace cronet
50 49
51 #endif // COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_ 50 #endif // COMPONENTS_CRONET_ANDROID_WRAPPED_CHANNEL_UPLOAD_ELEMENT_READER_H_
OLDNEW
« no previous file with comments | « components/cronet/android/url_request_peer.cc ('k') | components/cronet/android/wrapped_channel_upload_element_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698