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

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

Issue 10534100: Decouple URLRequestJob from URLRequestContext; access NetworkDelegate as a contructor parameter. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_job_factory.h" 5 #include "net/url_request/url_request_job_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "net/url_request/url_request.h"
10 #include "net/url_request/url_request_context.h"
9 #include "net/url_request/url_request_job.h" 11 #include "net/url_request/url_request_job.h"
10 #include "net/url_request/url_request_test_util.h" 12 #include "net/url_request/url_request_test_util.h"
11 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
12 14
13 namespace net { 15 namespace net {
14 16
15 namespace { 17 namespace {
16 18
17 class MockURLRequestJob : public URLRequestJob { 19 class MockURLRequestJob : public URLRequestJob {
18 public: 20 public:
19 MockURLRequestJob(URLRequest* request, const URLRequestStatus& status) 21 MockURLRequestJob(URLRequest* request, const URLRequestStatus& status)
20 : URLRequestJob(request), 22 : URLRequestJob(request, request->context()->network_delegate()),
21 status_(status), 23 status_(status),
22 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {} 24 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {}
23 25
24 virtual void Start() OVERRIDE { 26 virtual void Start() OVERRIDE {
25 // Start reading asynchronously so that all error reporting and data 27 // Start reading asynchronously so that all error reporting and data
26 // callbacks happen as they would for network requests. 28 // callbacks happen as they would for network requests.
27 MessageLoop::current()->PostTask( 29 MessageLoop::current()->PostTask(
28 FROM_HERE, 30 FROM_HERE,
29 base::Bind(&MockURLRequestJob::StartAsync, 31 base::Bind(&MockURLRequestJob::StartAsync,
30 weak_factory_.GetWeakPtr())); 32 weak_factory_.GetWeakPtr()));
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 EXPECT_FALSE(interceptor->WillHandleProtocol("anything")); 208 EXPECT_FALSE(interceptor->WillHandleProtocol("anything"));
207 EXPECT_FALSE(job_factory.IsHandledProtocol("anything")); 209 EXPECT_FALSE(job_factory.IsHandledProtocol("anything"));
208 interceptor->handle_all_protocols_ = true; 210 interceptor->handle_all_protocols_ = true;
209 EXPECT_TRUE(interceptor->WillHandleProtocol("anything")); 211 EXPECT_TRUE(interceptor->WillHandleProtocol("anything"));
210 EXPECT_TRUE(job_factory.IsHandledProtocol("anything")); 212 EXPECT_TRUE(job_factory.IsHandledProtocol("anything"));
211 } 213 }
212 214
213 } // namespace 215 } // namespace
214 216
215 } // namespace net 217 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698