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

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

Issue 2633123002: [Mojo-Loading] OnStartLoadingResponseBody should be called after OnReceiveResponse (Closed)
Patch Set: fix Created 3 years, 11 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 29 matching lines...) Expand all
40 URLResponseBodyConsumer::URLResponseBodyConsumer( 40 URLResponseBodyConsumer::URLResponseBodyConsumer(
41 int request_id, 41 int request_id,
42 ResourceDispatcher* resource_dispatcher, 42 ResourceDispatcher* resource_dispatcher,
43 mojo::ScopedDataPipeConsumerHandle handle, 43 mojo::ScopedDataPipeConsumerHandle handle,
44 scoped_refptr<base::SingleThreadTaskRunner> task_runner) 44 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
45 : request_id_(request_id), 45 : request_id_(request_id),
46 resource_dispatcher_(resource_dispatcher), 46 resource_dispatcher_(resource_dispatcher),
47 handle_(std::move(handle)), 47 handle_(std::move(handle)),
48 handle_watcher_(task_runner), 48 handle_watcher_(task_runner),
49 task_runner_(task_runner), 49 task_runner_(task_runner),
50 has_seen_end_of_data_(!handle_.is_valid()) {} 50 has_seen_end_of_data_(!handle_.is_valid()) {
51
52 URLResponseBodyConsumer::~URLResponseBodyConsumer() {}
53
54 void URLResponseBodyConsumer::Start() {
55 if (has_been_cancelled_)
56 return;
57 handle_watcher_.Start( 51 handle_watcher_.Start(
58 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE, 52 handle_.get(), MOJO_HANDLE_SIGNAL_READABLE,
59 base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this))); 53 base::Bind(&URLResponseBodyConsumer::OnReadable, base::Unretained(this)));
60 task_runner_->PostTask( 54 task_runner_->PostTask(
61 FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(), 55 FROM_HERE, base::Bind(&URLResponseBodyConsumer::OnReadable, AsWeakPtr(),
62 MOJO_RESULT_OK)); 56 MOJO_RESULT_OK));
63 } 57 }
64 58
59 URLResponseBodyConsumer::~URLResponseBodyConsumer() {}
60
65 void URLResponseBodyConsumer::OnComplete( 61 void URLResponseBodyConsumer::OnComplete(
66 const ResourceRequestCompletionStatus& status) { 62 const ResourceRequestCompletionStatus& status) {
67 if (has_been_cancelled_) 63 if (has_been_cancelled_)
68 return; 64 return;
69 has_received_completion_ = true; 65 has_received_completion_ = true;
70 completion_status_ = status; 66 completion_status_ = status;
71 NotifyCompletionIfAppropriate(); 67 NotifyCompletionIfAppropriate();
72 } 68 }
73 69
74 void URLResponseBodyConsumer::Cancel() { 70 void URLResponseBodyConsumer::Cancel() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return; 137 return;
142 // Cancel this instance in order not to notify twice. 138 // Cancel this instance in order not to notify twice.
143 Cancel(); 139 Cancel();
144 140
145 resource_dispatcher_->DispatchMessage( 141 resource_dispatcher_->DispatchMessage(
146 ResourceMsg_RequestComplete(request_id_, completion_status_)); 142 ResourceMsg_RequestComplete(request_id_, completion_status_));
147 // |this| may be deleted. 143 // |this| may be deleted.
148 } 144 }
149 145
150 } // namespace content 146 } // 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