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

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

Issue 667923003: Standardize usage of virtual/override/final in net/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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_impl.h" 5 #include "net/url_request/url_request_job_factory_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "net/base/request_priority.h" 10 #include "net/base/request_priority.h"
11 #include "net/url_request/url_request.h" 11 #include "net/url_request/url_request.h"
12 #include "net/url_request/url_request_job.h" 12 #include "net/url_request/url_request_job.h"
13 #include "net/url_request/url_request_test_util.h" 13 #include "net/url_request/url_request_test_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 namespace { 18 namespace {
19 19
20 class MockURLRequestJob : public URLRequestJob { 20 class MockURLRequestJob : public URLRequestJob {
21 public: 21 public:
22 MockURLRequestJob(URLRequest* request, 22 MockURLRequestJob(URLRequest* request,
23 NetworkDelegate* network_delegate, 23 NetworkDelegate* network_delegate,
24 const URLRequestStatus& status) 24 const URLRequestStatus& status)
25 : URLRequestJob(request, network_delegate), 25 : URLRequestJob(request, network_delegate),
26 status_(status), 26 status_(status),
27 weak_factory_(this) {} 27 weak_factory_(this) {}
28 28
29 virtual void Start() override { 29 void Start() override {
30 // Start reading asynchronously so that all error reporting and data 30 // Start reading asynchronously so that all error reporting and data
31 // callbacks happen as they would for network requests. 31 // callbacks happen as they would for network requests.
32 base::MessageLoop::current()->PostTask( 32 base::MessageLoop::current()->PostTask(
33 FROM_HERE, 33 FROM_HERE,
34 base::Bind(&MockURLRequestJob::StartAsync, weak_factory_.GetWeakPtr())); 34 base::Bind(&MockURLRequestJob::StartAsync, weak_factory_.GetWeakPtr()));
35 } 35 }
36 36
37 protected: 37 protected:
38 virtual ~MockURLRequestJob() {} 38 ~MockURLRequestJob() override {}
39 39
40 private: 40 private:
41 void StartAsync() { 41 void StartAsync() {
42 SetStatus(status_); 42 SetStatus(status_);
43 NotifyHeadersComplete(); 43 NotifyHeadersComplete();
44 } 44 }
45 45
46 URLRequestStatus status_; 46 URLRequestStatus status_;
47 base::WeakPtrFactory<MockURLRequestJob> weak_factory_; 47 base::WeakPtrFactory<MockURLRequestJob> weak_factory_;
48 }; 48 };
49 49
50 class DummyProtocolHandler : public URLRequestJobFactory::ProtocolHandler { 50 class DummyProtocolHandler : public URLRequestJobFactory::ProtocolHandler {
51 public: 51 public:
52 virtual URLRequestJob* MaybeCreateJob( 52 URLRequestJob* MaybeCreateJob(
53 URLRequest* request, NetworkDelegate* network_delegate) const override { 53 URLRequest* request,
54 NetworkDelegate* network_delegate) const override {
54 return new MockURLRequestJob( 55 return new MockURLRequestJob(
55 request, 56 request,
56 network_delegate, 57 network_delegate,
57 URLRequestStatus(URLRequestStatus::SUCCESS, OK)); 58 URLRequestStatus(URLRequestStatus::SUCCESS, OK));
58 } 59 }
59 }; 60 };
60 61
61 TEST(URLRequestJobFactoryTest, NoProtocolHandler) { 62 TEST(URLRequestJobFactoryTest, NoProtocolHandler) {
62 TestDelegate delegate; 63 TestDelegate delegate;
63 TestURLRequestContext request_context; 64 TestURLRequestContext request_context;
(...skipping 25 matching lines...) Expand all
89 URLRequestJobFactoryImpl job_factory; 90 URLRequestJobFactoryImpl job_factory;
90 TestURLRequestContext request_context; 91 TestURLRequestContext request_context;
91 request_context.set_job_factory(&job_factory); 92 request_context.set_job_factory(&job_factory);
92 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler); 93 job_factory.SetProtocolHandler("foo", new DummyProtocolHandler);
93 job_factory.SetProtocolHandler("foo", NULL); 94 job_factory.SetProtocolHandler("foo", NULL);
94 } 95 }
95 96
96 } // namespace 97 } // namespace
97 98
98 } // namespace net 99 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_job_factory_impl.h ('k') | net/url_request/url_request_redirect_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698