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

Side by Side Diff: net/proxy/mock_proxy_resolver.h

Issue 2817043: Reduce the copying of string data between C++ and javascript in proxy_resolver_v8.cc. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix comment typo 'converts' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « net/proxy/init_proxy_resolver_unittest.cc ('k') | net/proxy/proxy_resolver.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #ifndef NET_PROXY_MOCK_PROXY_RESOLVER_H_ 5 #ifndef NET_PROXY_MOCK_PROXY_RESOLVER_H_
6 #define NET_PROXY_MOCK_PROXY_RESOLVER_H_ 6 #define NET_PROXY_MOCK_PROXY_RESOLVER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const GURL url_; 54 const GURL url_;
55 ProxyInfo* results_; 55 ProxyInfo* results_;
56 CompletionCallback* callback_; 56 CompletionCallback* callback_;
57 MessageLoop* origin_loop_; 57 MessageLoop* origin_loop_;
58 }; 58 };
59 59
60 class SetPacScriptRequest { 60 class SetPacScriptRequest {
61 public: 61 public:
62 SetPacScriptRequest(MockAsyncProxyResolverBase* resolver, 62 SetPacScriptRequest(MockAsyncProxyResolverBase* resolver,
63 const GURL& pac_url, 63 const GURL& pac_url,
64 const std::string& pac_bytes, 64 const string16& pac_script,
65 CompletionCallback* callback) 65 CompletionCallback* callback)
66 : resolver_(resolver), 66 : resolver_(resolver),
67 pac_url_(pac_url), 67 pac_url_(pac_url),
68 pac_bytes_(pac_bytes), 68 pac_script_(pac_script),
69 callback_(callback), 69 callback_(callback),
70 origin_loop_(MessageLoop::current()) { 70 origin_loop_(MessageLoop::current()) {
71 } 71 }
72 72
73 const GURL& pac_url() const { return pac_url_; } 73 const GURL& pac_url() const { return pac_url_; }
74 const std::string& pac_bytes() const { return pac_bytes_; } 74 const string16& pac_script() const { return pac_script_; }
75 75
76 void CompleteNow(int rv) { 76 void CompleteNow(int rv) {
77 CompletionCallback* callback = callback_; 77 CompletionCallback* callback = callback_;
78 78
79 // Will delete |this|. 79 // Will delete |this|.
80 resolver_->RemovePendingSetPacScriptRequest(this); 80 resolver_->RemovePendingSetPacScriptRequest(this);
81 81
82 callback->Run(rv); 82 callback->Run(rv);
83 } 83 }
84 84
85 private: 85 private:
86 MockAsyncProxyResolverBase* resolver_; 86 MockAsyncProxyResolverBase* resolver_;
87 const GURL pac_url_; 87 const GURL pac_url_;
88 const std::string pac_bytes_; 88 const string16 pac_script_;
89 CompletionCallback* callback_; 89 CompletionCallback* callback_;
90 MessageLoop* origin_loop_; 90 MessageLoop* origin_loop_;
91 }; 91 };
92 92
93 typedef std::vector<scoped_refptr<Request> > RequestsList; 93 typedef std::vector<scoped_refptr<Request> > RequestsList;
94 94
95 // ProxyResolver implementation: 95 // ProxyResolver implementation:
96 virtual int GetProxyForURL(const GURL& url, 96 virtual int GetProxyForURL(const GURL& url,
97 ProxyInfo* results, 97 ProxyInfo* results,
98 CompletionCallback* callback, 98 CompletionCallback* callback,
99 RequestHandle* request_handle, 99 RequestHandle* request_handle,
100 const BoundNetLog& /*net_log*/) { 100 const BoundNetLog& /*net_log*/) {
101 scoped_refptr<Request> request = new Request(this, url, results, callback); 101 scoped_refptr<Request> request = new Request(this, url, results, callback);
102 pending_requests_.push_back(request); 102 pending_requests_.push_back(request);
103 103
104 if (request_handle) 104 if (request_handle)
105 *request_handle = reinterpret_cast<RequestHandle>(request.get()); 105 *request_handle = reinterpret_cast<RequestHandle>(request.get());
106 106
107 // Test code completes the request by calling request->CompleteNow(). 107 // Test code completes the request by calling request->CompleteNow().
108 return ERR_IO_PENDING; 108 return ERR_IO_PENDING;
109 } 109 }
110 110
111 virtual void CancelRequest(RequestHandle request_handle) { 111 virtual void CancelRequest(RequestHandle request_handle) {
112 scoped_refptr<Request> request = reinterpret_cast<Request*>(request_handle); 112 scoped_refptr<Request> request = reinterpret_cast<Request*>(request_handle);
113 cancelled_requests_.push_back(request); 113 cancelled_requests_.push_back(request);
114 RemovePendingRequest(request); 114 RemovePendingRequest(request);
115 } 115 }
116 116
117 virtual int SetPacScript(const GURL& pac_url, 117 virtual int SetPacScript(const GURL& pac_url,
118 const std::string& pac_bytes, 118 const string16& pac_script,
119 CompletionCallback* callback) { 119 CompletionCallback* callback) {
120 DCHECK(!pending_set_pac_script_request_.get()); 120 DCHECK(!pending_set_pac_script_request_.get());
121 pending_set_pac_script_request_.reset( 121 pending_set_pac_script_request_.reset(
122 new SetPacScriptRequest(this, pac_url, pac_bytes, callback)); 122 new SetPacScriptRequest(this, pac_url, pac_script, callback));
123 // Finished when user calls SetPacScriptRequest::CompleteNow(). 123 // Finished when user calls SetPacScriptRequest::CompleteNow().
124 return ERR_IO_PENDING; 124 return ERR_IO_PENDING;
125 } 125 }
126 126
127 virtual void CancelSetPacScript() { 127 virtual void CancelSetPacScript() {
128 // Do nothing (caller was responsible for completing the request). 128 // Do nothing (caller was responsible for completing the request).
129 } 129 }
130 130
131 const RequestsList& pending_requests() const { 131 const RequestsList& pending_requests() const {
132 return pending_requests_; 132 return pending_requests_;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 class MockAsyncProxyResolverExpectsBytes : public MockAsyncProxyResolverBase { 171 class MockAsyncProxyResolverExpectsBytes : public MockAsyncProxyResolverBase {
172 public: 172 public:
173 MockAsyncProxyResolverExpectsBytes() 173 MockAsyncProxyResolverExpectsBytes()
174 : MockAsyncProxyResolverBase(true /*expects_pac_bytes*/) {} 174 : MockAsyncProxyResolverBase(true /*expects_pac_bytes*/) {}
175 }; 175 };
176 176
177 } // namespace net 177 } // namespace net
178 178
179 #endif // NET_PROXY_MOCK_PROXY_RESOLVER_H_ 179 #endif // NET_PROXY_MOCK_PROXY_RESOLVER_H_
OLDNEW
« no previous file with comments | « net/proxy/init_proxy_resolver_unittest.cc ('k') | net/proxy/proxy_resolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698