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

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

Issue 2466263008: Revert of [Mojo-Loading] Dispatch body data after response is received (Closed)
Patch Set: Created 4 years, 1 month 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/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "content/child/resource_dispatcher.h" 10 #include "content/child/resource_dispatcher.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_(task_runner), 51 handle_watcher_(task_runner),
52 has_seen_end_of_data_(!handle_.is_valid()) {} 52 has_seen_end_of_data_(!handle_.is_valid()) {
53
54 URLResponseBodyConsumer::~URLResponseBodyConsumer() {}
55
56 void URLResponseBodyConsumer::Start(base::SingleThreadTaskRunner* task_runner) {
57 if (has_been_cancelled_)
58 return;
59 handle_watcher_.Start( 53 handle_watcher_.Start(
60 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, 54 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE,
61 base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this))); 55 base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this)));
62 task_runner->PostTask( 56 task_runner->PostTask(
63 FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(), 57 FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(),
64 MOJO_RESULT_OK)); 58 MOJO_RESULT_OK));
65 } 59 }
66 60
61 URLResponseBodyConsumer::~URLResponseBodyConsumer() {}
62
67 void URLResponseBodyConsumer::OnComplete( 63 void URLResponseBodyConsumer::OnComplete(
68 const ResourceRequestCompletionStatus& status) { 64 const ResourceRequestCompletionStatus& status) {
69 if (has_been_cancelled_) 65 if (has_been_cancelled_)
70 return; 66 return;
71 has_received_completion_ = true; 67 has_received_completion_ = true;
72 completion_status_ = status; 68 completion_status_ = status;
73 NotifyCompletionIfAppropriate(); 69 NotifyCompletionIfAppropriate();
74 } 70 }
75 71
76 void URLResponseBodyConsumer::Cancel() { 72 void URLResponseBodyConsumer::Cancel() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return; 118 return;
123 // Cancel this instance in order not to notify twice. 119 // Cancel this instance in order not to notify twice.
124 Cancel(); 120 Cancel();
125 121
126 resource_dispatcher_->OnMessageReceived( 122 resource_dispatcher_->OnMessageReceived(
127 ResourceMsg_RequestComplete(request_id_, completion_status_)); 123 ResourceMsg_RequestComplete(request_id_, completion_status_));
128 // |this| may be deleted. 124 // |this| may be deleted.
129 } 125 }
130 126
131 } // namespace content 127 } // namespace content
OLDNEW
« no previous file with comments | « content/child/url_response_body_consumer.h ('k') | content/child/url_response_body_consumer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698