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

Side by Side Diff: ios/net/protocol_handler_util_unittest.mm

Issue 1295523006: Using scoped_ptr for URLRequestJobFactoryImpl::SetProtocolHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/mac/scoped_nsobject.h" 5 #include "base/mac/scoped_nsobject.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "ios/net/protocol_handler_util.h" 10 #import "ios/net/protocol_handler_util.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 NetworkDelegate* network_delegate) const override { 103 NetworkDelegate* network_delegate) const override {
104 return new HeadersURLRequestJob(request); 104 return new HeadersURLRequestJob(request);
105 } 105 }
106 }; 106 };
107 107
108 class ProtocolHandlerUtilTest : public testing::Test, 108 class ProtocolHandlerUtilTest : public testing::Test,
109 public URLRequest::Delegate { 109 public URLRequest::Delegate {
110 public: 110 public:
111 ProtocolHandlerUtilTest() : request_context_(new TestURLRequestContext) { 111 ProtocolHandlerUtilTest() : request_context_(new TestURLRequestContext) {
112 // Ownership of the protocol handlers is transferred to the factory. 112 // Ownership of the protocol handlers is transferred to the factory.
113 job_factory_.SetProtocolHandler("http", new NetProtocolHandler); 113 job_factory_.SetProtocolHandler("http",
114 job_factory_.SetProtocolHandler("data", new DataProtocolHandler); 114 make_scoped_ptr(new NetProtocolHandler));
115 job_factory_.SetProtocolHandler("data",
116 make_scoped_ptr(new DataProtocolHandler));
115 request_context_->set_job_factory(&job_factory_); 117 request_context_->set_job_factory(&job_factory_);
116 } 118 }
117 119
118 NSURLResponse* BuildDataURLResponse(const std::string& mime_type, 120 NSURLResponse* BuildDataURLResponse(const std::string& mime_type,
119 const std::string& encoding, 121 const std::string& encoding,
120 const std::string& content) { 122 const std::string& content) {
121 // Build an URL in the form "data:<mime_type>;charset=<encoding>,<content>" 123 // Build an URL in the form "data:<mime_type>;charset=<encoding>,<content>"
122 // The ';' is removed if mime_type or charset is empty. 124 // The ';' is removed if mime_type or charset is empty.
123 std::string url_string = std::string("data:") + mime_type; 125 std::string url_string = std::string("data:") + mime_type;
124 if (!encoding.empty()) 126 if (!encoding.empty())
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 // Some headers are added by default if missing. 267 // Some headers are added by default if missing.
266 const HttpRequestHeaders& headers = out_request->extra_request_headers(); 268 const HttpRequestHeaders& headers = out_request->extra_request_headers();
267 std::string header; 269 std::string header;
268 EXPECT_TRUE(headers.GetHeader("Accept", &header)); 270 EXPECT_TRUE(headers.GetHeader("Accept", &header));
269 EXPECT_EQ("*/*", header); 271 EXPECT_EQ("*/*", header);
270 EXPECT_TRUE(headers.GetHeader("Content-Type", &header)); 272 EXPECT_TRUE(headers.GetHeader("Content-Type", &header));
271 EXPECT_EQ("application/x-www-form-urlencoded", header); 273 EXPECT_EQ("application/x-www-form-urlencoded", header);
272 } 274 }
273 275
274 } // namespace net 276 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698