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

Side by Side Diff: components/cronet/android/test/upload_data_stream_handler.h

Issue 849903002: [Cronet] Upload support for async APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_CRONET_ANDROID_TEST_UPLOAD_DATA_STREAM_HANDLER_H_
6 #define COMPONENTS_CRONET_ANDROID_TEST_UPLOAD_DATA_STREAM_HANDLER_H_
7
8 #include <jni.h>
9
10 #include "components/cronet/android/cronet_upload_data_stream_adapter.h"
11 #include "base/android/scoped_java_ref.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/thread.h"
16 #include "net/base/io_buffer.h"
17
18 namespace cronet {
19
20 class UploadDataStreamHandler {
mmenke 2015/01/21 18:48:58 This doesn't need to be in the header. Can be in
xunjieli 2015/01/21 23:49:24 Done.
21 public:
22 class Delegate {
mmenke 2015/01/21 18:48:58 You don't need both this and UploadDataStreamHandl
xunjieli 2015/01/21 23:49:24 Done. Good idea! I have inlined the methods.
23 public:
24 Delegate() {}
25 virtual ~Delegate() {}
26 virtual void OnInitCalled(int res);
27 virtual void OnReadCompleted(int res);
28 virtual void OnInitCompleted(int res);
29 virtual void OnResetCompleted();
30 virtual void OnCheckIfReadCallbackInvoked(bool res);
31 virtual void OnCheckIfInitCallbackInvoked(bool res);
32 };
33
34 UploadDataStreamHandler(CronetUploadDataStreamAdapter* adapter,
35 JNIEnv* env,
36 jobject jupload_data_stream_handler);
37 ~UploadDataStreamHandler();
38
39 void Init();
40 void Read();
41 void Reset();
42 void InitDelegate(JNIEnv* env, jobject jupload_stream_handler);
43 scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() const;
44 std::string Data() const;
45 void CheckIfInitCallbackInvoked();
46 void CheckIfReadCallbackInvoked();
47
48 private:
49 void OnInitComplete(int res);
50 void OnReadComplete(int res);
51 void InitOnNetworkThread();
52 void ReadOnNetworkThread();
53 void ResetOnNetworkThread();
54 void CheckIfInitCallbackInvokedOnNetworkThread();
55 void CheckIfReadCallbackInvokedOnNetworkThread();
56
57 bool init_complete_;
58 bool read_complete_;
59 int bytes_read_;
60
61 base::Thread* network_thread_;
62 scoped_ptr<CronetUploadDataStreamAdapter> adapter_;
63 base::WeakPtrFactory<UploadDataStreamHandler> weak_factory_;
64 scoped_ptr<Delegate> delegate_;
65 scoped_refptr<net::IOBufferWithSize> read_buffer_;
66
67 DISALLOW_COPY_AND_ASSIGN(UploadDataStreamHandler);
68 };
69
70 bool UploadDataStreamHandlerRegisterJni(JNIEnv* env);
71
72 } // namespace cronet
73
74 #endif // COMPONENTS_CRONET_ANDROID_TEST_UPLOAD_DATA_STREAM_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698