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

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: Merged with latest sync Created 8 years, 5 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
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/url_request/url_request_redirect_job.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 EXPECT_FALSE(interceptor->WillHandleProtocol("anything")); 201 EXPECT_FALSE(interceptor->WillHandleProtocol("anything"));
200 EXPECT_FALSE(job_factory.IsHandledProtocol("anything")); 202 EXPECT_FALSE(job_factory.IsHandledProtocol("anything"));
201 interceptor->handle_all_protocols_ = true; 203 interceptor->handle_all_protocols_ = true;
202 EXPECT_TRUE(interceptor->WillHandleProtocol("anything")); 204 EXPECT_TRUE(interceptor->WillHandleProtocol("anything"));
203 EXPECT_TRUE(job_factory.IsHandledProtocol("anything")); 205 EXPECT_TRUE(job_factory.IsHandledProtocol("anything"));
204 } 206 }
205 207
206 } // namespace 208 } // namespace
207 209
208 } // namespace net 210 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_job.cc ('k') | net/url_request/url_request_redirect_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698