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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api_unittest.cc

Issue 11439008: net: Change argument of URLRequest::set_upload from UploadData to UploadDataStream (Closed) Base URL: http://git.chromium.org/chromium/src.git@chunk
Patch Set: Fix android Created 8 years 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 | « no previous file | chrome/browser/net/chrome_fraudulent_certificate_reporter.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) 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 <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/common/extensions/features/feature.h" 32 #include "chrome/common/extensions/features/feature.h"
33 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
34 #include "chrome/test/base/testing_browser_process.h" 34 #include "chrome/test/base/testing_browser_process.h"
35 #include "chrome/test/base/testing_pref_service.h" 35 #include "chrome/test/base/testing_pref_service.h"
36 #include "chrome/test/base/testing_profile.h" 36 #include "chrome/test/base/testing_profile.h"
37 #include "content/public/test/test_browser_thread.h" 37 #include "content/public/test/test_browser_thread.h"
38 #include "net/base/auth.h" 38 #include "net/base/auth.h"
39 #include "net/base/capturing_net_log.h" 39 #include "net/base/capturing_net_log.h"
40 #include "net/base/mock_host_resolver.h" 40 #include "net/base/mock_host_resolver.h"
41 #include "net/base/net_util.h" 41 #include "net/base/net_util.h"
42 #include "net/base/upload_data.h" 42 #include "net/base/upload_bytes_element_reader.h"
43 #include "net/base/upload_data_stream.h"
44 #include "net/base/upload_file_element_reader.h"
43 #include "net/url_request/url_request_test_util.h" 45 #include "net/url_request/url_request_test_util.h"
44 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
45 47
46 namespace helpers = extension_web_request_api_helpers; 48 namespace helpers = extension_web_request_api_helpers;
47 namespace keys = extension_web_request_api_constants; 49 namespace keys = extension_web_request_api_constants;
48 50
49 using base::BinaryValue; 51 using base::BinaryValue;
50 using base::DictionaryValue; 52 using base::DictionaryValue;
51 using base::ListValue; 53 using base::ListValue;
52 using base::StringValue; 54 using base::StringValue;
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 const std::vector<char>& bytes_1, 484 const std::vector<char>& bytes_1,
483 const std::vector<char>& bytes_2) { 485 const std::vector<char>& bytes_2) {
484 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme. 486 // The request URL can be arbitrary but must have an HTTP or HTTPS scheme.
485 GURL request_url("http://www.example.com"); 487 GURL request_url("http://www.example.com");
486 net::URLRequest request(request_url, &delegate_, context_.get()); 488 net::URLRequest request(request_url, &delegate_, context_.get());
487 request.set_method(method); 489 request.set_method(method);
488 if (content_type != NULL) 490 if (content_type != NULL)
489 request.SetExtraRequestHeaderByName(net::HttpRequestHeaders::kContentType, 491 request.SetExtraRequestHeaderByName(net::HttpRequestHeaders::kContentType,
490 content_type, 492 content_type,
491 true /* overwrite */); 493 true /* overwrite */);
492 scoped_refptr<net::UploadData> upload_data(new net::UploadData()); 494 ScopedVector<net::UploadElementReader> element_readers;
493 upload_data->AppendBytes(&(bytes_1[0]), bytes_1.size()); 495 element_readers.push_back(new net::UploadBytesElementReader(
494 upload_data->AppendFileRange(::FilePath(), 0, 0, base::Time()); 496 &(bytes_1[0]), bytes_1.size()));
495 upload_data->AppendBytes(&(bytes_2[0]), bytes_2.size()); 497 element_readers.push_back(new net::UploadFileElementReader(
496 request.set_upload(upload_data); 498 ::FilePath(), 0, 0, base::Time()));
499 element_readers.push_back(new net::UploadBytesElementReader(
500 &(bytes_2[0]), bytes_2.size()));
501 request.set_upload(make_scoped_ptr(
502 new net::UploadDataStream(&element_readers, 0)));
497 ipc_sender_.PushTask(base::Bind(&base::DoNothing)); 503 ipc_sender_.PushTask(base::Bind(&base::DoNothing));
498 request.Start(); 504 request.Start();
499 } 505 }
500 506
501 TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) { 507 TEST_F(ExtensionWebRequestTest, AccessRequestBodyData) {
502 // We verify that URLRequest body is accessible to OnBeforeRequest listeners. 508 // We verify that URLRequest body is accessible to OnBeforeRequest listeners.
503 // These testing steps are repeated twice in a row: 509 // These testing steps are repeated twice in a row:
504 // 1. Register an extension requesting "requestBody" in ExtraInfoSpec and 510 // 1. Register an extension requesting "requestBody" in ExtraInfoSpec and
505 // file a POST URLRequest with a multipart-encoded form. See it getting 511 // file a POST URLRequest with a multipart-encoded form. See it getting
506 // parsed. 512 // parsed.
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 EXPECT_TRUE(credentials_set); 2146 EXPECT_TRUE(credentials_set);
2141 EXPECT_FALSE(auth3.Empty()); 2147 EXPECT_FALSE(auth3.Empty());
2142 EXPECT_EQ(username, auth1.username()); 2148 EXPECT_EQ(username, auth1.username());
2143 EXPECT_EQ(password, auth1.password()); 2149 EXPECT_EQ(password, auth1.password());
2144 EXPECT_EQ(1u, warning_set.size()); 2150 EXPECT_EQ(1u, warning_set.size());
2145 EXPECT_TRUE(HasWarning(warning_set, "extid2")); 2151 EXPECT_TRUE(HasWarning(warning_set, "extid2"));
2146 EXPECT_EQ(3u, capturing_net_log.GetSize()); 2152 EXPECT_EQ(3u, capturing_net_log.GetSize());
2147 } 2153 }
2148 2154
2149 } // namespace extensions 2155 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/chrome_fraudulent_certificate_reporter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698