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

Side by Side Diff: content/child/shared_memory_data_consumer_handle.h

Issue 2177243002: Use per-frame TaskRunner instead of thread's default in DataConsumerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@data_consumer_handle_unique_ptr
Patch Set: update Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ 5 #ifndef CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ 6 #define CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "content/common/content_export.h" 15 #include "content/common/content_export.h"
16 #include "content/public/child/request_peer.h" 16 #include "content/public/child/request_peer.h"
17 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h" 17 #include "third_party/WebKit/public/platform/WebDataConsumerHandle.h"
18 18
19 namespace base {
20 class SingleThreadTaskRunner;
21 }
22
19 namespace content { 23 namespace content {
20 24
21 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData. 25 // This class is a WebDataConsumerHandle that accepts RequestPeer::ReceivedData.
22 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final 26 class CONTENT_EXPORT SharedMemoryDataConsumerHandle final
23 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle) { 27 : public NON_EXPORTED_BASE(blink::WebDataConsumerHandle) {
24 private: 28 private:
25 class Context; 29 class Context;
26 30
27 public: 31 public:
28 enum BackpressureMode { 32 enum BackpressureMode {
(...skipping 14 matching lines...) Expand all
43 47
44 private: 48 private:
45 scoped_refptr<Context> context_; 49 scoped_refptr<Context> context_;
46 BackpressureMode mode_; 50 BackpressureMode mode_;
47 51
48 DISALLOW_COPY_AND_ASSIGN(Writer); 52 DISALLOW_COPY_AND_ASSIGN(Writer);
49 }; 53 };
50 54
51 class ReaderImpl final : public Reader { 55 class ReaderImpl final : public Reader {
52 public: 56 public:
53 ReaderImpl(scoped_refptr<Context> context, Client* client); 57 ReaderImpl(scoped_refptr<Context> context, Client* client,
58 scoped_refptr<base::SingleThreadTaskRunner> reader_task_runner);
54 ~ReaderImpl() override; 59 ~ReaderImpl() override;
55 Result read(void* data, 60 Result read(void* data,
56 size_t size, 61 size_t size,
57 Flags flags, 62 Flags flags,
58 size_t* readSize) override; 63 size_t* readSize) override;
59 Result beginRead(const void** buffer, 64 Result beginRead(const void** buffer,
60 Flags flags, 65 Flags flags,
61 size_t* available) override; 66 size_t* available) override;
62 Result endRead(size_t readSize) override; 67 Result endRead(size_t readSize) override;
63 68
(...skipping 10 matching lines...) Expand all
74 // |on_reader_detached| will be called aynchronously on the calling thread 79 // |on_reader_detached| will be called aynchronously on the calling thread
75 // when the reader (including the handle) is detached (i.e. both the handle 80 // when the reader (including the handle) is detached (i.e. both the handle
76 // and the reader are destructed). The callback will be reset in the internal 81 // and the reader are destructed). The callback will be reset in the internal
77 // context when the writer is detached, i.e. |Close| or |Fail| is called, 82 // context when the writer is detached, i.e. |Close| or |Fail| is called,
78 // and the callback will never be called. 83 // and the callback will never be called.
79 SharedMemoryDataConsumerHandle(BackpressureMode mode, 84 SharedMemoryDataConsumerHandle(BackpressureMode mode,
80 const base::Closure& on_reader_detached, 85 const base::Closure& on_reader_detached,
81 std::unique_ptr<Writer>* writer); 86 std::unique_ptr<Writer>* writer);
82 ~SharedMemoryDataConsumerHandle() override; 87 ~SharedMemoryDataConsumerHandle() override;
83 88
84 std::unique_ptr<Reader> obtainReader(Client* client) override; 89 // Unlike to other Reader, |reader_task_runner| here is nullable, so that
90 // the test code don't need to create blink::WebTaskRunner.
91 std::unique_ptr<Reader> obtainReader(
92 Client* client,
93 std::unique_ptr<blink::WebTaskRunner> reader_task_runner) override;
85 94
86 private: 95 private:
87 const char* debugName() const override; 96 const char* debugName() const override;
88 97
89 scoped_refptr<Context> context_; 98 scoped_refptr<Context> context_;
90 99
91 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle); 100 DISALLOW_COPY_AND_ASSIGN(SharedMemoryDataConsumerHandle);
92 }; 101 };
93 102
94 } // namespace content 103 } // namespace content
95 104
96 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_ 105 #endif // CONTENT_CHILD_SHARED_MEMORY_DATA_CONSUMER_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698