- remove mojo_view_manager_lib_unittests from chrome_tests.py
[chromium-blink-merge.git] / content / child / threaded_data_provider.h
blob55ae060eaa93c4d09f9b77f881cacb3be3ceb98e
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.
5 #ifndef CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_
6 #define CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_
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"
17 namespace blink {
18 class WebThreadedDataReceiver;
21 namespace IPC {
22 class SyncChannel;
25 namespace content {
26 class WebThreadImpl;
28 class ThreadedDataProvider {
29 public:
30 ThreadedDataProvider(
31 int request_id,
32 blink::WebThreadedDataReceiver* threaded_data_receiver,
33 linked_ptr<base::SharedMemory> shm_buffer,
34 int shm_size);
35 virtual ~ThreadedDataProvider();
37 void Stop();
38 void OnReceivedDataOnBackgroundThread(int data_offset,
39 int data_length,
40 int encoded_data_length);
42 void OnReceivedDataOnForegroundThread(const char* data,
43 int data_length,
44 int encoded_data_length);
46 void OnResourceMessageFilterAddedMainThread();
48 private:
49 void StopOnBackgroundThread();
50 void OnResourceMessageFilterAddedBackgroundThread();
51 void ForwardAndACKData(const char* data, int data_length);
53 scoped_refptr<IPC::MessageFilter> filter_;
54 int request_id_;
55 linked_ptr<base::SharedMemory> shm_buffer_;
56 int shm_size_;
57 scoped_ptr<base::WeakPtrFactory<ThreadedDataProvider> >
58 background_thread_weak_factory_;
59 base::WeakPtrFactory<ThreadedDataProvider>
60 main_thread_weak_factory_;
61 WebThreadImpl& background_thread_;
62 IPC::SyncChannel* ipc_channel_;
63 blink::WebThreadedDataReceiver* threaded_data_receiver_;
64 bool resource_filter_active_;
65 base::MessageLoop* main_thread_message_loop_;
67 struct QueuedSharedMemoryData {
68 const char* data;
69 int length;
71 std::vector<QueuedSharedMemoryData> queued_data_;
73 DISALLOW_COPY_AND_ASSIGN(ThreadedDataProvider);
76 } // namespace content
78 #endif // CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_