OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/network_delegate_error_observer.h" | 5 #include "net/proxy/network_delegate_error_observer.h" |
6 | 6 |
7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 #include "net/base/network_delegate.h" | 10 #include "net/base/network_delegate.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 TestNetworkDelegate() : got_pac_error_(false) {} | 21 TestNetworkDelegate() : got_pac_error_(false) {} |
22 virtual ~TestNetworkDelegate() {} | 22 virtual ~TestNetworkDelegate() {} |
23 | 23 |
24 bool got_pac_error() const { return got_pac_error_; } | 24 bool got_pac_error() const { return got_pac_error_; } |
25 | 25 |
26 private: | 26 private: |
27 // net::NetworkDelegate: | 27 // net::NetworkDelegate: |
28 virtual int OnBeforeURLRequest(URLRequest* request, | 28 virtual int OnBeforeURLRequest(URLRequest* request, |
29 CompletionCallback* callback, | 29 CompletionCallback* callback, |
30 GURL* new_url) OVERRIDE { | 30 GURL* new_url) OVERRIDE { |
31 return net::OK; | 31 return OK; |
32 } | 32 } |
33 virtual int OnBeforeSendHeaders(URLRequest* request, | 33 virtual int OnBeforeSendHeaders(URLRequest* request, |
34 CompletionCallback* callback, | 34 CompletionCallback* callback, |
35 HttpRequestHeaders* headers) OVERRIDE { | 35 HttpRequestHeaders* headers) OVERRIDE { |
36 return net::OK; | 36 return OK; |
37 } | 37 } |
38 virtual void OnSendHeaders(URLRequest* request, | 38 virtual void OnSendHeaders(URLRequest* request, |
39 const HttpRequestHeaders& headers) OVERRIDE {} | 39 const HttpRequestHeaders& headers) OVERRIDE {} |
40 virtual void OnBeforeRedirect(URLRequest* request, | 40 virtual void OnBeforeRedirect(URLRequest* request, |
41 const GURL& new_location) OVERRIDE {} | 41 const GURL& new_location) OVERRIDE {} |
42 virtual void OnResponseStarted(URLRequest* request) OVERRIDE {} | 42 virtual void OnResponseStarted(URLRequest* request) OVERRIDE {} |
43 virtual void OnRawBytesRead(const URLRequest& request, | 43 virtual void OnRawBytesRead(const URLRequest& request, |
44 int bytes_read) OVERRIDE {} | 44 int bytes_read) OVERRIDE {} |
45 virtual void OnCompleted(URLRequest* request) OVERRIDE {} | 45 virtual void OnCompleted(URLRequest* request) OVERRIDE {} |
46 virtual void OnURLRequestDestroyed(URLRequest* request) OVERRIDE {} | 46 virtual void OnURLRequestDestroyed(URLRequest* request) OVERRIDE {} |
47 | 47 |
48 virtual void OnPACScriptError(int line_number, | 48 virtual void OnPACScriptError(int line_number, |
49 const string16& error) OVERRIDE { | 49 const string16& error) OVERRIDE { |
50 got_pac_error_ = true; | 50 got_pac_error_ = true; |
51 } | 51 } |
52 virtual void OnAuthRequired(URLRequest* request, | 52 virtual int OnAuthRequired(URLRequest* request, |
53 const AuthChallengeInfo& auth_info) OVERRIDE {} | 53 const AuthChallengeInfo& auth_info, |
| 54 CompletionCallback* callback, |
| 55 AuthCredentials* credentials) OVERRIDE { |
| 56 return OK; |
| 57 } |
54 | 58 |
55 bool got_pac_error_; | 59 bool got_pac_error_; |
56 }; | 60 }; |
57 | 61 |
58 } // namespace | 62 } // namespace |
59 | 63 |
60 // Check that the OnPACScriptError method can be called from an arbitrary | 64 // Check that the OnPACScriptError method can be called from an arbitrary |
61 // thread. | 65 // thread. |
62 TEST(NetworkDelegateErrorObserverTest, CallOnThread) { | 66 TEST(NetworkDelegateErrorObserverTest, CallOnThread) { |
63 base::Thread thread("test_thread"); | 67 base::Thread thread("test_thread"); |
(...skipping 22 matching lines...) Expand all Loading... |
86 FROM_HERE, | 90 FROM_HERE, |
87 NewRunnableMethod(&observer, | 91 NewRunnableMethod(&observer, |
88 &NetworkDelegateErrorObserver::OnPACScriptError, | 92 &NetworkDelegateErrorObserver::OnPACScriptError, |
89 42, string16())); | 93 42, string16())); |
90 thread.Stop(); | 94 thread.Stop(); |
91 MessageLoop::current()->RunAllPending(); | 95 MessageLoop::current()->RunAllPending(); |
92 // Shouldn't have crashed until here... | 96 // Shouldn't have crashed until here... |
93 } | 97 } |
94 | 98 |
95 } // namespace net | 99 } // namespace net |
OLD | NEW |