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"
18 class WebThreadedDataReceiver
;
28 class ThreadedDataProvider
{
32 blink::WebThreadedDataReceiver
* threaded_data_receiver
,
33 linked_ptr
<base::SharedMemory
> shm_buffer
,
35 scoped_refptr
<base::SingleThreadTaskRunner
> main_thread_task_runner_
);
36 virtual ~ThreadedDataProvider();
39 void OnReceivedDataOnBackgroundThread(int data_offset
,
41 int encoded_data_length
);
43 void OnReceivedDataOnForegroundThread(const char* data
,
45 int encoded_data_length
);
47 void OnResourceMessageFilterAddedMainThread();
50 void StopOnBackgroundThread();
51 void OnResourceMessageFilterAddedBackgroundThread();
52 void ForwardAndACKData(const char* data
, int data_length
);
54 scoped_refptr
<IPC::MessageFilter
> filter_
;
56 linked_ptr
<base::SharedMemory
> shm_buffer_
;
58 scoped_ptr
<base::WeakPtrFactory
<ThreadedDataProvider
> >
59 background_thread_weak_factory_
;
60 WebThreadImpl
& background_thread_
;
61 IPC::SyncChannel
* ipc_channel_
;
62 blink::WebThreadedDataReceiver
* threaded_data_receiver_
;
63 bool resource_filter_active_
;
64 scoped_refptr
<base::SingleThreadTaskRunner
> main_thread_task_runner_
;
66 struct QueuedSharedMemoryData
{
70 std::vector
<QueuedSharedMemoryData
> queued_data_
;
72 base::WeakPtrFactory
<ThreadedDataProvider
>
73 main_thread_weak_factory_
;
75 DISALLOW_COPY_AND_ASSIGN(ThreadedDataProvider
);
78 } // namespace content
80 #endif // CONTENT_CHILD_THREADEDDATAPROVIDER_IMPL_H_