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

Side by Side Diff: net/proxy/proxy_resolver_v8_tracing_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
« no previous file with comments | « net/proxy/proxy_resolver_v8_tracing.cc ('k') | net/proxy/proxy_resolver_v8_unittest.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/proxy/proxy_resolver_v8_tracing.h" 5 #include "net/proxy/proxy_resolver_v8_tracing.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 int rv = 63 int rv =
64 resolver->SetPacScript(LoadScriptData(filename), callback.callback()); 64 resolver->SetPacScript(LoadScriptData(filename), callback.callback());
65 EXPECT_EQ(ERR_IO_PENDING, rv); 65 EXPECT_EQ(ERR_IO_PENDING, rv);
66 EXPECT_EQ(OK, callback.WaitForResult()); 66 EXPECT_EQ(OK, callback.WaitForResult());
67 } 67 }
68 68
69 class MockErrorObserver : public ProxyResolverErrorObserver { 69 class MockErrorObserver : public ProxyResolverErrorObserver {
70 public: 70 public:
71 MockErrorObserver() : event_(true, false) {} 71 MockErrorObserver() : event_(true, false) {}
72 72
73 virtual void OnPACScriptError(int line_number, 73 void OnPACScriptError(int line_number, const base::string16& error) override {
74 const base::string16& error) override {
75 { 74 {
76 base::AutoLock l(lock_); 75 base::AutoLock l(lock_);
77 output += base::StringPrintf("Error: line %d: %s\n", line_number, 76 output += base::StringPrintf("Error: line %d: %s\n", line_number,
78 base::UTF16ToASCII(error).c_str()); 77 base::UTF16ToASCII(error).c_str());
79 } 78 }
80 event_.Signal(); 79 event_.Signal();
81 } 80 }
82 81
83 std::string GetOutput() { 82 std::string GetOutput() {
84 base::AutoLock l(lock_); 83 base::AutoLock l(lock_);
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 proxy_info3.proxy_server().ToURI()); 755 proxy_info3.proxy_server().ToURI());
757 } 756 }
758 757
759 // This implementation of HostResolver allows blocking until a resolve request 758 // This implementation of HostResolver allows blocking until a resolve request
760 // has been received. The resolve requests it receives will never be completed. 759 // has been received. The resolve requests it receives will never be completed.
761 class BlockableHostResolver : public HostResolver { 760 class BlockableHostResolver : public HostResolver {
762 public: 761 public:
763 BlockableHostResolver() 762 BlockableHostResolver()
764 : num_cancelled_requests_(0), waiting_for_resolve_(false) {} 763 : num_cancelled_requests_(0), waiting_for_resolve_(false) {}
765 764
766 virtual int Resolve(const RequestInfo& info, 765 int Resolve(const RequestInfo& info,
767 RequestPriority priority, 766 RequestPriority priority,
768 AddressList* addresses, 767 AddressList* addresses,
769 const CompletionCallback& callback, 768 const CompletionCallback& callback,
770 RequestHandle* out_req, 769 RequestHandle* out_req,
771 const BoundNetLog& net_log) override { 770 const BoundNetLog& net_log) override {
772 EXPECT_FALSE(callback.is_null()); 771 EXPECT_FALSE(callback.is_null());
773 EXPECT_TRUE(out_req); 772 EXPECT_TRUE(out_req);
774 773
775 if (!action_.is_null()) 774 if (!action_.is_null())
776 action_.Run(); 775 action_.Run();
777 776
778 // Indicate to the caller that a request was received. 777 // Indicate to the caller that a request was received.
779 EXPECT_TRUE(waiting_for_resolve_); 778 EXPECT_TRUE(waiting_for_resolve_);
780 base::MessageLoop::current()->Quit(); 779 base::MessageLoop::current()->Quit();
781 780
782 // This line is intentionally after action_.Run(), since one of the 781 // This line is intentionally after action_.Run(), since one of the
783 // tests does a cancellation inside of Resolve(), and it is more 782 // tests does a cancellation inside of Resolve(), and it is more
784 // interesting if *out_req hasn't been written yet at that point. 783 // interesting if *out_req hasn't been written yet at that point.
785 *out_req = reinterpret_cast<RequestHandle*>(1); // Magic value. 784 *out_req = reinterpret_cast<RequestHandle*>(1); // Magic value.
786 785
787 // Return ERR_IO_PENDING as this request will NEVER be completed. 786 // Return ERR_IO_PENDING as this request will NEVER be completed.
788 // Expectation is for the caller to later cancel the request. 787 // Expectation is for the caller to later cancel the request.
789 return ERR_IO_PENDING; 788 return ERR_IO_PENDING;
790 } 789 }
791 790
792 virtual int ResolveFromCache(const RequestInfo& info, 791 int ResolveFromCache(const RequestInfo& info,
793 AddressList* addresses, 792 AddressList* addresses,
794 const BoundNetLog& net_log) override { 793 const BoundNetLog& net_log) override {
795 NOTREACHED(); 794 NOTREACHED();
796 return ERR_DNS_CACHE_MISS; 795 return ERR_DNS_CACHE_MISS;
797 } 796 }
798 797
799 virtual void CancelRequest(RequestHandle req) override { 798 void CancelRequest(RequestHandle req) override {
800 EXPECT_EQ(reinterpret_cast<RequestHandle*>(1), req); 799 EXPECT_EQ(reinterpret_cast<RequestHandle*>(1), req);
801 num_cancelled_requests_++; 800 num_cancelled_requests_++;
802 } 801 }
803 802
804 void SetAction(const base::Callback<void(void)>& action) { 803 void SetAction(const base::Callback<void(void)>& action) {
805 action_ = action; 804 action_ = action;
806 } 805 }
807 806
808 // Waits until Resolve() has been called. 807 // Waits until Resolve() has been called.
809 void WaitUntilRequestIsReceived() { 808 void WaitUntilRequestIsReceived() {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 proxy_uri.substr(0, proxy_uri.find(':') + 1)); 1089 proxy_uri.substr(0, proxy_uri.find(':') + 1));
1091 } else { 1090 } else {
1092 NOTREACHED(); 1091 NOTREACHED();
1093 } 1092 }
1094 } 1093 }
1095 } 1094 }
1096 1095
1097 } // namespace 1096 } // namespace
1098 1097
1099 } // namespace net 1098 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8_tracing.cc ('k') | net/proxy/proxy_resolver_v8_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698