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

Side by Side Diff: content/child/web_data_consumer_handle_impl.cc

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: . Created 3 years, 9 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
« no previous file with comments | « content/child/web_data_consumer_handle_impl.h ('k') | content/common/message_port.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #include "content/child/web_data_consumer_handle_impl.h" 5 #include "content/child/web_data_consumer_handle_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 19 matching lines...) Expand all
30 friend class base::RefCountedThreadSafe<Context>; 30 friend class base::RefCountedThreadSafe<Context>;
31 ~Context() {} 31 ~Context() {}
32 Handle handle_; 32 Handle handle_;
33 33
34 DISALLOW_COPY_AND_ASSIGN(Context); 34 DISALLOW_COPY_AND_ASSIGN(Context);
35 }; 35 };
36 36
37 WebDataConsumerHandleImpl::ReaderImpl::ReaderImpl( 37 WebDataConsumerHandleImpl::ReaderImpl::ReaderImpl(
38 scoped_refptr<Context> context, 38 scoped_refptr<Context> context,
39 Client* client) 39 Client* client)
40 : context_(context), handle_watcher_(FROM_HERE), client_(client) { 40 : context_(context),
41 handle_watcher_(FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::AUTOMATIC),
42 client_(client) {
41 if (client_) 43 if (client_)
42 StartWatching(); 44 StartWatching();
43 } 45 }
44 46
45 WebDataConsumerHandleImpl::ReaderImpl::~ReaderImpl() { 47 WebDataConsumerHandleImpl::ReaderImpl::~ReaderImpl() {
46 } 48 }
47 49
48 Result WebDataConsumerHandleImpl::ReaderImpl::read(void* data, 50 Result WebDataConsumerHandleImpl::ReaderImpl::read(void* data,
49 size_t size, 51 size_t size,
50 Flags flags, 52 Flags flags,
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 case MOJO_RESULT_SHOULD_WAIT: 125 case MOJO_RESULT_SHOULD_WAIT:
124 return ShouldWait; 126 return ShouldWait;
125 case MOJO_RESULT_RESOURCE_EXHAUSTED: 127 case MOJO_RESULT_RESOURCE_EXHAUSTED:
126 return ResourceExhausted; 128 return ResourceExhausted;
127 default: 129 default:
128 return UnexpectedError; 130 return UnexpectedError;
129 } 131 }
130 } 132 }
131 133
132 void WebDataConsumerHandleImpl::ReaderImpl::StartWatching() { 134 void WebDataConsumerHandleImpl::ReaderImpl::StartWatching() {
133 handle_watcher_.Start( 135 handle_watcher_.Watch(
134 context_->handle().get(), MOJO_HANDLE_SIGNAL_READABLE, 136 context_->handle().get(), MOJO_HANDLE_SIGNAL_READABLE,
135 base::Bind(&ReaderImpl::OnHandleGotReadable, base::Unretained(this))); 137 base::Bind(&ReaderImpl::OnHandleGotReadable, base::Unretained(this)));
136 } 138 }
137 139
138 void WebDataConsumerHandleImpl::ReaderImpl::OnHandleGotReadable(MojoResult) { 140 void WebDataConsumerHandleImpl::ReaderImpl::OnHandleGotReadable(MojoResult) {
139 DCHECK(client_); 141 DCHECK(client_);
140 client_->didGetReadable(); 142 client_->didGetReadable();
141 } 143 }
142 144
143 WebDataConsumerHandleImpl::WebDataConsumerHandleImpl(Handle handle) 145 WebDataConsumerHandleImpl::WebDataConsumerHandleImpl(Handle handle)
144 : context_(new Context(std::move(handle))) {} 146 : context_(new Context(std::move(handle))) {}
145 147
146 WebDataConsumerHandleImpl::~WebDataConsumerHandleImpl() { 148 WebDataConsumerHandleImpl::~WebDataConsumerHandleImpl() {
147 } 149 }
148 150
149 std::unique_ptr<blink::WebDataConsumerHandle::Reader> 151 std::unique_ptr<blink::WebDataConsumerHandle::Reader>
150 WebDataConsumerHandleImpl::obtainReader(Client* client) { 152 WebDataConsumerHandleImpl::obtainReader(Client* client) {
151 return base::WrapUnique(new ReaderImpl(context_, client)); 153 return base::WrapUnique(new ReaderImpl(context_, client));
152 } 154 }
153 155
154 const char* WebDataConsumerHandleImpl::debugName() const { 156 const char* WebDataConsumerHandleImpl::debugName() const {
155 return "WebDataConsumerHandleImpl"; 157 return "WebDataConsumerHandleImpl";
156 } 158 }
157 159
158 } // namespace content 160 } // namespace content
OLDNEW
« no previous file with comments | « content/child/web_data_consumer_handle_impl.h ('k') | content/common/message_port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698