OLD | NEW |
| (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 CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_ | |
6 #define CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/linked_ptr.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/shared_memory.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "ipc/ipc_channel.h" | |
15 #include "ipc/message_filter.h" | |
16 | |
17 namespace blink { | |
18 class WebThreadedDataReceiver; | |
19 } | |
20 | |
21 namespace IPC { | |
22 class SyncChannel; | |
23 } | |
24 | |
25 namespace webkit_glue { | |
26 class WebThreadImpl; | |
27 } | |
28 | |
29 namespace content { | |
30 class ResourceDispatcher; | |
31 class WebThreadImpl; | |
32 | |
33 class ThreadedDataProvider { | |
34 public: | |
35 ThreadedDataProvider( | |
36 int request_id, | |
37 blink::WebThreadedDataReceiver* threaded_data_receiver, | |
38 linked_ptr<base::SharedMemory> shm_buffer, | |
39 int shm_size); | |
40 virtual ~ThreadedDataProvider(); | |
41 | |
42 void Stop(); | |
43 void OnReceivedDataOnBackgroundThread(int data_offset, | |
44 int data_length, | |
45 int encoded_data_length); | |
46 | |
47 void OnReceivedDataOnForegroundThread(const char* data, | |
48 int data_length, | |
49 int encoded_data_length); | |
50 | |
51 void OnResourceMessageFilterAddedMainThread(); | |
52 | |
53 private: | |
54 void StopOnBackgroundThread(); | |
55 void OnResourceMessageFilterAddedBackgroundThread(); | |
56 void ForwardAndACKData(const char* data, int data_length); | |
57 | |
58 scoped_refptr<IPC::MessageFilter> filter_; | |
59 int request_id_; | |
60 linked_ptr<base::SharedMemory> shm_buffer_; | |
61 int shm_size_; | |
62 scoped_ptr<base::WeakPtrFactory<ThreadedDataProvider> > | |
63 background_thread_weak_factory_; | |
64 base::WeakPtrFactory<ThreadedDataProvider> | |
65 main_thread_weak_factory_; | |
66 WebThreadImpl& background_thread_; | |
67 IPC::SyncChannel* ipc_channel_; | |
68 blink::WebThreadedDataReceiver* threaded_data_receiver_; | |
69 bool resource_filter_active_; | |
70 base::MessageLoop* main_thread_message_loop_; | |
71 | |
72 struct QueuedSharedMemoryData { | |
73 const char* data; | |
74 int length; | |
75 }; | |
76 std::vector<QueuedSharedMemoryData> queued_data_; | |
77 | |
78 DISALLOW_COPY_AND_ASSIGN(ThreadedDataProvider); | |
79 }; | |
80 | |
81 } // namespace content | |
82 | |
83 #endif // CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_ | |
OLD | NEW |