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

Side by Side Diff: net/url_request/url_request_simple_job_unittest.cc

Issue 2891363005: Add ScopedTaskEnvironment::ExecutionControlMode. (Closed)
Patch Set: self-review Created 3 years, 7 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 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 "net/url_request/url_request_simple_job.h" 5 #include "net/url_request/url_request_simple_job.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 public: 74 public:
75 CancelAfterFirstReadURLRequestDelegate() : run_loop_(new base::RunLoop) {} 75 CancelAfterFirstReadURLRequestDelegate() : run_loop_(new base::RunLoop) {}
76 76
77 ~CancelAfterFirstReadURLRequestDelegate() override {} 77 ~CancelAfterFirstReadURLRequestDelegate() override {}
78 78
79 void OnResponseStarted(URLRequest* request, int net_error) override { 79 void OnResponseStarted(URLRequest* request, int net_error) override {
80 DCHECK_NE(ERR_IO_PENDING, net_error); 80 DCHECK_NE(ERR_IO_PENDING, net_error);
81 // net::TestDelegate will start the first read. 81 // net::TestDelegate will start the first read.
82 TestDelegate::OnResponseStarted(request, net_error); 82 TestDelegate::OnResponseStarted(request, net_error);
83 request->Cancel(); 83 request->Cancel();
84 run_loop_->Quit(); 84 run_loop_->QuitWhenIdle();
85 } 85 }
86 86
87 void WaitUntilHeadersReceived() const { run_loop_->Run(); } 87 void WaitUntilHeadersReceived() const { run_loop_->Run(); }
88 88
89 private: 89 private:
90 std::unique_ptr<base::RunLoop> run_loop_; 90 std::unique_ptr<base::RunLoop> run_loop_;
91 91
92 DISALLOW_COPY_AND_ASSIGN(CancelAfterFirstReadURLRequestDelegate); 92 DISALLOW_COPY_AND_ASSIGN(CancelAfterFirstReadURLRequestDelegate);
93 }; 93 };
94 94
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 NetTestSuite::GetScopedTaskEnvironment()->RunUntilIdle(); 224 NetTestSuite::GetScopedTaskEnvironment()->RunUntilIdle();
225 225
226 EXPECT_THAT(cancel_delegate.request_status(), IsError(ERR_ABORTED)); 226 EXPECT_THAT(cancel_delegate.request_status(), IsError(ERR_ABORTED));
227 EXPECT_EQ(1, cancel_delegate.response_started_count()); 227 EXPECT_EQ(1, cancel_delegate.response_started_count());
228 EXPECT_EQ("", cancel_delegate.data_received()); 228 EXPECT_EQ("", cancel_delegate.data_received());
229 // Destroy the request so it doesn't outlive its delegate. 229 // Destroy the request so it doesn't outlive its delegate.
230 request_.reset(); 230 request_.reset();
231 } 231 }
232 232
233 } // namespace net 233 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698