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

Side by Side Diff: content/child/url_response_body_consumer.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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/url_response_body_consumer.h" 5 #include "content/child/url_response_body_consumer.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 30 matching lines...) Expand all
41 }; 41 };
42 42
43 URLResponseBodyConsumer::URLResponseBodyConsumer( 43 URLResponseBodyConsumer::URLResponseBodyConsumer(
44 int request_id, 44 int request_id,
45 ResourceDispatcher* resource_dispatcher, 45 ResourceDispatcher* resource_dispatcher,
46 mojo::ScopedDataPipeConsumerHandle handle, 46 mojo::ScopedDataPipeConsumerHandle handle,
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 47 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
48 : request_id_(request_id), 48 : request_id_(request_id),
49 resource_dispatcher_(resource_dispatcher), 49 resource_dispatcher_(resource_dispatcher),
50 handle_(std::move(handle)), 50 handle_(std::move(handle)),
51 handle_watcher_(FROM_HERE, task_runner), 51 handle_watcher_(FROM_HERE,
52 mojo::Watcher::ArmingPolicy::AUTOMATIC,
53 task_runner),
52 task_runner_(task_runner), 54 task_runner_(task_runner),
53 has_seen_end_of_data_(!handle_.is_valid()) { 55 has_seen_end_of_data_(!handle_.is_valid()) {
54 handle_watcher_.Start( 56 handle_watcher_.Start(
55 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, 57 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE,
56 base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this))); 58 base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this)));
57 task_runner_->PostTask( 59 task_runner_->PostTask(
58 FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(), 60 FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(),
yzshen1 2017/03/11 00:44:58 We may not need weak ptr support for this class an
Ken Rockot(use gerrit already) 2017/03/12 22:24:13 I think that's true, but I'd rather leave this unc
59 MOJO_RESULT_OK)); 61 MOJO_RESULT_OK));
60 } 62 }
61 63
62 URLResponseBodyConsumer::~URLResponseBodyConsumer() {} 64 URLResponseBodyConsumer::~URLResponseBodyConsumer() {}
63 65
64 void URLResponseBodyConsumer::OnComplete( 66 void URLResponseBodyConsumer::OnComplete(
65 const ResourceRequestCompletionStatus& status) { 67 const ResourceRequestCompletionStatus& status) {
66 if (has_been_cancelled_) 68 if (has_been_cancelled_)
67 return; 69 return;
68 has_received_completion_ = true; 70 has_received_completion_ = true;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 return; 167 return;
166 // Cancel this instance in order not to notify twice. 168 // Cancel this instance in order not to notify twice.
167 Cancel(); 169 Cancel();
168 170
169 resource_dispatcher_->DispatchMessage( 171 resource_dispatcher_->DispatchMessage(
170 ResourceMsg_RequestComplete(request_id_, completion_status_)); 172 ResourceMsg_RequestComplete(request_id_, completion_status_));
171 // |this| may be deleted. 173 // |this| may be deleted.
172 } 174 }
173 175
174 } // namespace content 176 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698