Commit 49c44f6b authored by meacer's avatar meacer Committed by Commit bot

Remove unused CookiePreferences from report sender and never send cookies

All non-test callers of ReportSender use CookiePreferences::DO_NOT_SEND_COOKIES.
Remove the enum altogether.

BUG=716098

Review-Url: https://codereview.chromium.org/2851493003
Cr-Commit-Position: refs/heads/master@{#468150}
parent 10cd268f
...@@ -1039,8 +1039,8 @@ void ProfileIOData::Init( ...@@ -1039,8 +1039,8 @@ void ProfileIOData::Init(
base::SequencedWorkerPool::BLOCK_SHUTDOWN), base::SequencedWorkerPool::BLOCK_SHUTDOWN),
IsOffTheRecord())); IsOffTheRecord()));
certificate_report_sender_.reset(new net::ReportSender( certificate_report_sender_.reset(
main_request_context_.get(), net::ReportSender::DO_NOT_SEND_COOKIES)); new net::ReportSender(main_request_context_.get()));
transport_security_state_->SetReportSender(certificate_report_sender_.get()); transport_security_state_->SetReportSender(certificate_report_sender_.get());
expect_ct_reporter_.reset( expect_ct_reporter_.reset(
......
...@@ -305,15 +305,14 @@ void CertificateReportingService::ResetOnIOThread( ...@@ -305,15 +305,14 @@ void CertificateReportingService::ResetOnIOThread(
std::unique_ptr<certificate_reporting::ErrorReporter> error_reporter; std::unique_ptr<certificate_reporting::ErrorReporter> error_reporter;
if (server_public_key) { if (server_public_key) {
// Only used in tests. // Only used in tests.
std::unique_ptr<net::ReportSender> report_sender(new net::ReportSender( std::unique_ptr<net::ReportSender> report_sender(
url_request_context, net::ReportSender::DO_NOT_SEND_COOKIES)); new net::ReportSender(url_request_context));
error_reporter.reset(new certificate_reporting::ErrorReporter( error_reporter.reset(new certificate_reporting::ErrorReporter(
GURL(kExtendedReportingUploadUrl), server_public_key, GURL(kExtendedReportingUploadUrl), server_public_key,
server_public_key_version, std::move(report_sender))); server_public_key_version, std::move(report_sender)));
} else { } else {
error_reporter.reset(new certificate_reporting::ErrorReporter( error_reporter.reset(new certificate_reporting::ErrorReporter(
url_request_context, GURL(kExtendedReportingUploadUrl), url_request_context, GURL(kExtendedReportingUploadUrl)));
net::ReportSender::DO_NOT_SEND_COOKIES));
} }
reporter_.reset( reporter_.reset(
new Reporter(std::move(error_reporter), new Reporter(std::move(error_reporter),
......
...@@ -205,8 +205,7 @@ TEST_F(CertificateReportingServiceReporterOnIOThreadTest, ...@@ -205,8 +205,7 @@ TEST_F(CertificateReportingServiceReporterOnIOThreadTest,
net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR); net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR);
certificate_reporting::ErrorReporter* certificate_error_reporter = certificate_reporting::ErrorReporter* certificate_error_reporter =
new certificate_reporting::ErrorReporter( new certificate_reporting::ErrorReporter(
url_request_context_getter()->GetURLRequestContext(), kFailureURL, url_request_context_getter()->GetURLRequestContext(), kFailureURL);
net::ReportSender::DO_NOT_SEND_COOKIES);
CertificateReportingService::BoundedReportList* list = CertificateReportingService::BoundedReportList* list =
new CertificateReportingService::BoundedReportList(2); new CertificateReportingService::BoundedReportList(2);
...@@ -296,8 +295,7 @@ TEST_F(CertificateReportingServiceReporterOnIOThreadTest, ...@@ -296,8 +295,7 @@ TEST_F(CertificateReportingServiceReporterOnIOThreadTest,
net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR); net::URLRequestFailedJob::GetMockHttpsUrl(net::ERR_SSL_PROTOCOL_ERROR);
certificate_reporting::ErrorReporter* certificate_error_reporter = certificate_reporting::ErrorReporter* certificate_error_reporter =
new certificate_reporting::ErrorReporter( new certificate_reporting::ErrorReporter(
url_request_context_getter()->GetURLRequestContext(), kFailureURL, url_request_context_getter()->GetURLRequestContext(), kFailureURL);
net::ReportSender::DO_NOT_SEND_COOKIES);
CertificateReportingService::BoundedReportList* list = CertificateReportingService::BoundedReportList* list =
new CertificateReportingService::BoundedReportList(2); new CertificateReportingService::BoundedReportList(2);
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
namespace safe_browsing { namespace safe_browsing {
MockPermissionReportSender::MockPermissionReportSender() MockPermissionReportSender::MockPermissionReportSender()
: net::ReportSender(nullptr, DO_NOT_SEND_COOKIES), : net::ReportSender(nullptr), number_of_reports_(0) {
number_of_reports_(0) {
DCHECK(quit_closure_.is_null()); DCHECK(quit_closure_.is_null());
} }
......
...@@ -59,9 +59,8 @@ const char NotificationImageReporter::kReportingUploadUrl[] = ...@@ -59,9 +59,8 @@ const char NotificationImageReporter::kReportingUploadUrl[] =
NotificationImageReporter::NotificationImageReporter( NotificationImageReporter::NotificationImageReporter(
net::URLRequestContext* request_context) net::URLRequestContext* request_context)
: NotificationImageReporter(base::MakeUnique<net::ReportSender>( : NotificationImageReporter(
request_context, base::MakeUnique<net::ReportSender>(request_context)) {}
net::ReportSender::CookiesPreference::DO_NOT_SEND_COOKIES)) {}
NotificationImageReporter::NotificationImageReporter( NotificationImageReporter::NotificationImageReporter(
std::unique_ptr<net::ReportSender> report_sender) std::unique_ptr<net::ReportSender> report_sender)
......
...@@ -144,11 +144,8 @@ std::size_t PermissionAndOriginHash::operator()( ...@@ -144,11 +144,8 @@ std::size_t PermissionAndOriginHash::operator()(
} }
PermissionReporter::PermissionReporter(net::URLRequestContext* request_context) PermissionReporter::PermissionReporter(net::URLRequestContext* request_context)
: PermissionReporter( : PermissionReporter(base::MakeUnique<net::ReportSender>(request_context),
base::MakeUnique<net::ReportSender>( base::WrapUnique(new base::DefaultClock)) {}
request_context,
net::ReportSender::CookiesPreference::DO_NOT_SEND_COOKIES),
base::WrapUnique(new base::DefaultClock)) {}
PermissionReporter::PermissionReporter( PermissionReporter::PermissionReporter(
std::unique_ptr<net::ReportSender> report_sender, std::unique_ptr<net::ReportSender> report_sender,
......
...@@ -116,9 +116,7 @@ void RecordUMAOnFailure(const GURL& report_uri, ...@@ -116,9 +116,7 @@ void RecordUMAOnFailure(const GURL& report_uri,
ChromeExpectCTReporter::ChromeExpectCTReporter( ChromeExpectCTReporter::ChromeExpectCTReporter(
net::URLRequestContext* request_context) net::URLRequestContext* request_context)
: report_sender_( : report_sender_(new net::ReportSender(request_context)) {}
new net::ReportSender(request_context,
net::ReportSender::DO_NOT_SEND_COOKIES)) {}
ChromeExpectCTReporter::~ChromeExpectCTReporter() {} ChromeExpectCTReporter::~ChromeExpectCTReporter() {}
......
...@@ -35,8 +35,7 @@ const char kFailureHistogramName[] = "SSL.ExpectCTReportFailure2"; ...@@ -35,8 +35,7 @@ const char kFailureHistogramName[] = "SSL.ExpectCTReportFailure2";
// serialized report to be sent. // serialized report to be sent.
class TestCertificateReportSender : public net::ReportSender { class TestCertificateReportSender : public net::ReportSender {
public: public:
TestCertificateReportSender() TestCertificateReportSender() : ReportSender(nullptr) {}
: ReportSender(nullptr, net::ReportSender::DO_NOT_SEND_COOKIES) {}
~TestCertificateReportSender() override {} ~TestCertificateReportSender() override {}
void Send(const GURL& report_uri, void Send(const GURL& report_uri,
......
...@@ -100,15 +100,12 @@ bool EncryptSerializedReport(const uint8_t* server_public_key, ...@@ -100,15 +100,12 @@ bool EncryptSerializedReport(const uint8_t* server_public_key,
} // namespace } // namespace
ErrorReporter::ErrorReporter( ErrorReporter::ErrorReporter(net::URLRequestContext* request_context,
net::URLRequestContext* request_context, const GURL& upload_url)
const GURL& upload_url,
net::ReportSender::CookiesPreference cookies_preference)
: ErrorReporter(upload_url, : ErrorReporter(upload_url,
kServerPublicKey, kServerPublicKey,
kServerPublicKeyVersion, kServerPublicKeyVersion,
base::MakeUnique<net::ReportSender>(request_context, base::MakeUnique<net::ReportSender>(request_context)) {}
cookies_preference)) {}
ErrorReporter::ErrorReporter( ErrorReporter::ErrorReporter(
const GURL& upload_url, const GURL& upload_url,
......
...@@ -30,11 +30,9 @@ class ErrorReporter { ...@@ -30,11 +30,9 @@ class ErrorReporter {
public: public:
// Creates a certificate error reporter that will send certificate // Creates a certificate error reporter that will send certificate
// error reports to |upload_url|, using |request_context| as the // error reports to |upload_url|, using |request_context| as the
// context for the reports. |cookies_preference| controls whether // context for the reports.
// cookies will be sent along with the reports.
ErrorReporter(net::URLRequestContext* request_context, ErrorReporter(net::URLRequestContext* request_context,
const GURL& upload_url, const GURL& upload_url);
net::ReportSender::CookiesPreference cookies_preference);
// Allows tests to use a server public key with known private key and // Allows tests to use a server public key with known private key and
// a mock ReportSender. |server_public_key| must outlive // a mock ReportSender. |server_public_key| must outlive
......
...@@ -51,8 +51,7 @@ void SuccessCallback(bool* called) { ...@@ -51,8 +51,7 @@ void SuccessCallback(bool* called) {
// sent. // sent.
class MockCertificateReportSender : public net::ReportSender { class MockCertificateReportSender : public net::ReportSender {
public: public:
MockCertificateReportSender() MockCertificateReportSender() : net::ReportSender(nullptr) {}
: net::ReportSender(nullptr, DO_NOT_SEND_COOKIES) {}
~MockCertificateReportSender() override {} ~MockCertificateReportSender() override {}
void Send(const GURL& report_uri, void Send(const GURL& report_uri,
...@@ -179,8 +178,7 @@ TEST_F(ErrorReporterTest, ErroredRequestCallsCallback) { ...@@ -179,8 +178,7 @@ TEST_F(ErrorReporterTest, ErroredRequestCallsCallback) {
const GURL report_uri( const GURL report_uri(
net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_FAILED)); net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_CONNECTION_FAILED));
ErrorReporter reporter(&context, report_uri, ErrorReporter reporter(&context, report_uri);
net::ReportSender::DO_NOT_SEND_COOKIES);
bool error_callback_called = false; bool error_callback_called = false;
bool success_callback_called = false; bool success_callback_called = false;
...@@ -206,8 +204,7 @@ TEST_F(ErrorReporterTest, SuccessfulRequestCallsCallback) { ...@@ -206,8 +204,7 @@ TEST_F(ErrorReporterTest, SuccessfulRequestCallsCallback) {
const GURL report_uri( const GURL report_uri(
net::URLRequestMockDataJob::GetMockHttpUrl("some data", 1)); net::URLRequestMockDataJob::GetMockHttpUrl("some data", 1));
ErrorReporter reporter(&context, report_uri, ErrorReporter reporter(&context, report_uri);
net::ReportSender::DO_NOT_SEND_COOKIES);
bool error_callback_called = false; bool error_callback_called = false;
bool success_callback_called = false; bool success_callback_called = false;
......
...@@ -363,8 +363,8 @@ void ChromeBrowserStateIOData::Init( ...@@ -363,8 +363,8 @@ void ChromeBrowserStateIOData::Init(
pool->GetSequenceToken(), base::SequencedWorkerPool::BLOCK_SHUTDOWN), pool->GetSequenceToken(), base::SequencedWorkerPool::BLOCK_SHUTDOWN),
IsOffTheRecord())); IsOffTheRecord()));
certificate_report_sender_.reset(new net::ReportSender( certificate_report_sender_ =
main_request_context_.get(), net::ReportSender::DO_NOT_SEND_COOKIES)); base::MakeUnique<net::ReportSender>(main_request_context_.get());
transport_security_state_->SetReportSender(certificate_report_sender_.get()); transport_security_state_->SetReportSender(certificate_report_sender_.get());
// Take ownership over these parameters. // Take ownership over these parameters.
......
...@@ -41,10 +41,8 @@ class CallbackInfo : public base::SupportsUserData::Data { ...@@ -41,10 +41,8 @@ class CallbackInfo : public base::SupportsUserData::Data {
namespace net { namespace net {
ReportSender::ReportSender(URLRequestContext* request_context, ReportSender::ReportSender(URLRequestContext* request_context)
CookiesPreference cookies_preference) : request_context_(request_context) {}
: request_context_(request_context),
cookies_preference_(cookies_preference) {}
ReportSender::~ReportSender() { ReportSender::~ReportSender() {
} }
...@@ -61,12 +59,9 @@ void ReportSender::Send(const GURL& report_uri, ...@@ -61,12 +59,9 @@ void ReportSender::Send(const GURL& report_uri,
&kUserDataKey, &kUserDataKey,
base::MakeUnique<CallbackInfo>(success_callback, error_callback)); base::MakeUnique<CallbackInfo>(success_callback, error_callback));
int load_flags = url_request->SetLoadFlags(
LOAD_BYPASS_CACHE | LOAD_DISABLE_CACHE | LOAD_DO_NOT_SEND_AUTH_DATA; LOAD_BYPASS_CACHE | LOAD_DISABLE_CACHE | LOAD_DO_NOT_SEND_AUTH_DATA |
if (cookies_preference_ != SEND_COOKIES) { LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES);
load_flags |= LOAD_DO_NOT_SEND_COOKIES | LOAD_DO_NOT_SAVE_COOKIES;
}
url_request->SetLoadFlags(load_flags);
HttpRequestHeaders extra_headers; HttpRequestHeaders extra_headers;
extra_headers.SetHeader(HttpRequestHeaders::kContentType, content_type); extra_headers.SetHeader(HttpRequestHeaders::kContentType, content_type);
......
...@@ -34,15 +34,10 @@ class NET_EXPORT ReportSender ...@@ -34,15 +34,10 @@ class NET_EXPORT ReportSender
using ErrorCallback = base::Callback< using ErrorCallback = base::Callback<
void(const GURL&, int /* net_error */, int /* http_response_code */)>; void(const GURL&, int /* net_error */, int /* http_response_code */)>;
// Represents whether or not to send cookies along with reports.
enum CookiesPreference { SEND_COOKIES, DO_NOT_SEND_COOKIES };
// Constructs a ReportSender that sends reports with the // Constructs a ReportSender that sends reports with the
// given |request_context| and includes or excludes cookies based on // given |request_context|, always excluding cookies. |request_context| must
// |cookies_preference|. |request_context| must outlive the // outlive the ReportSender.
// ReportSender. explicit ReportSender(URLRequestContext* request_context);
ReportSender(URLRequestContext* request_context,
CookiesPreference cookies_preference);
~ReportSender() override; ~ReportSender() override;
...@@ -59,9 +54,6 @@ class NET_EXPORT ReportSender ...@@ -59,9 +54,6 @@ class NET_EXPORT ReportSender
private: private:
net::URLRequestContext* const request_context_; net::URLRequestContext* const request_context_;
CookiesPreference cookies_preference_;
std::map<URLRequest*, std::unique_ptr<URLRequest>> inflight_requests_; std::map<URLRequest*, std::unique_ptr<URLRequest>> inflight_requests_;
DISALLOW_COPY_AND_ASSIGN(ReportSender); DISALLOW_COPY_AND_ASSIGN(ReportSender);
......
...@@ -120,8 +120,7 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl { ...@@ -120,8 +120,7 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl {
TestReportSenderNetworkDelegate() TestReportSenderNetworkDelegate()
: url_request_destroyed_callback_(base::Bind(&base::DoNothing)), : url_request_destroyed_callback_(base::Bind(&base::DoNothing)),
all_url_requests_destroyed_callback_(base::Bind(&base::DoNothing)), all_url_requests_destroyed_callback_(base::Bind(&base::DoNothing)),
num_requests_(0), num_requests_(0) {}
expect_cookies_(false) {}
void ExpectReport(const std::string& report) { void ExpectReport(const std::string& report) {
expect_reports_.insert(report); expect_reports_.insert(report);
...@@ -139,11 +138,6 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl { ...@@ -139,11 +138,6 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl {
size_t num_requests() const { return num_requests_; } size_t num_requests() const { return num_requests_; }
// Sets whether cookies are expected to be sent on requests.
void set_expect_cookies(bool expect_cookies) {
expect_cookies_ = expect_cookies;
}
void set_expected_content_type(const std::string& content_type) { void set_expected_content_type(const std::string& content_type) {
expected_content_type_ = content_type; expected_content_type_ = content_type;
} }
...@@ -155,14 +149,8 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl { ...@@ -155,14 +149,8 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl {
num_requests_++; num_requests_++;
EXPECT_EQ(expect_url_, request->url()); EXPECT_EQ(expect_url_, request->url());
EXPECT_STRCASEEQ("POST", request->method().data()); EXPECT_STRCASEEQ("POST", request->method().data());
EXPECT_TRUE(request->load_flags() & LOAD_DO_NOT_SEND_COOKIES);
if (expect_cookies_) { EXPECT_TRUE(request->load_flags() & LOAD_DO_NOT_SAVE_COOKIES);
EXPECT_FALSE(request->load_flags() & LOAD_DO_NOT_SEND_COOKIES);
EXPECT_FALSE(request->load_flags() & LOAD_DO_NOT_SAVE_COOKIES);
} else {
EXPECT_TRUE(request->load_flags() & LOAD_DO_NOT_SEND_COOKIES);
EXPECT_TRUE(request->load_flags() & LOAD_DO_NOT_SAVE_COOKIES);
}
const HttpRequestHeaders& extra_headers = request->extra_request_headers(); const HttpRequestHeaders& extra_headers = request->extra_request_headers();
std::string content_type; std::string content_type;
...@@ -189,7 +177,6 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl { ...@@ -189,7 +177,6 @@ class TestReportSenderNetworkDelegate : public NetworkDelegateImpl {
size_t num_requests_; size_t num_requests_;
GURL expect_url_; GURL expect_url_;
std::set<std::string> expect_reports_; std::set<std::string> expect_reports_;
bool expect_cookies_;
std::string expected_content_type_; std::string expected_content_type_;
DISALLOW_COPY_AND_ASSIGN(TestReportSenderNetworkDelegate); DISALLOW_COPY_AND_ASSIGN(TestReportSenderNetworkDelegate);
...@@ -263,13 +250,13 @@ class ReportSenderTest : public ::testing::Test { ...@@ -263,13 +250,13 @@ class ReportSenderTest : public ::testing::Test {
// endpoint and sends the expected data. // endpoint and sends the expected data.
TEST_F(ReportSenderTest, SendsRequest) { TEST_F(ReportSenderTest, SendsRequest) {
GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1); GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
SendReport(&reporter, kDummyReport, url, 0); SendReport(&reporter, kDummyReport, url, 0);
} }
TEST_F(ReportSenderTest, SendMultipleReportsSequentially) { TEST_F(ReportSenderTest, SendMultipleReportsSequentially) {
GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1); GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
SendReport(&reporter, kDummyReport, url, 0); SendReport(&reporter, kDummyReport, url, 0);
SendReport(&reporter, kDummyReport, url, 1); SendReport(&reporter, kDummyReport, url, 1);
} }
...@@ -285,7 +272,7 @@ TEST_F(ReportSenderTest, SendMultipleReportsSimultaneously) { ...@@ -285,7 +272,7 @@ TEST_F(ReportSenderTest, SendMultipleReportsSimultaneously) {
network_delegate_.ExpectReport(kSecondDummyReport); network_delegate_.ExpectReport(kSecondDummyReport);
network_delegate_.set_expected_content_type("application/foobar"); network_delegate_.set_expected_content_type("application/foobar");
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
EXPECT_EQ(0u, network_delegate_.num_requests()); EXPECT_EQ(0u, network_delegate_.num_requests());
...@@ -316,8 +303,7 @@ TEST_F(ReportSenderTest, PendingRequestGetsDeleted) { ...@@ -316,8 +303,7 @@ TEST_F(ReportSenderTest, PendingRequestGetsDeleted) {
EXPECT_EQ(0u, network_delegate_.num_requests()); EXPECT_EQ(0u, network_delegate_.num_requests());
std::unique_ptr<ReportSender> reporter( std::unique_ptr<ReportSender> reporter(new ReportSender(context()));
new ReportSender(context(), ReportSender::DO_NOT_SEND_COOKIES));
reporter->Send(url, "application/foobar", kDummyReport, reporter->Send(url, "application/foobar", kDummyReport,
base::Callback<void()>(), base::Callback<void()>(),
base::Callback<void(const GURL&, int, int)>()); base::Callback<void(const GURL&, int, int)>());
...@@ -330,7 +316,7 @@ TEST_F(ReportSenderTest, PendingRequestGetsDeleted) { ...@@ -330,7 +316,7 @@ TEST_F(ReportSenderTest, PendingRequestGetsDeleted) {
// Test that a request that returns an error gets cleaned up. // Test that a request that returns an error gets cleaned up.
TEST_F(ReportSenderTest, ErroredRequestGetsDeleted) { TEST_F(ReportSenderTest, ErroredRequestGetsDeleted) {
GURL url = URLRequestFailedJob::GetMockHttpsUrl(ERR_FAILED); GURL url = URLRequestFailedJob::GetMockHttpsUrl(ERR_FAILED);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
// SendReport will block until the URLRequest is destroyed. // SendReport will block until the URLRequest is destroyed.
SendReport(&reporter, kDummyReport, url, 0); SendReport(&reporter, kDummyReport, url, 0);
} }
...@@ -341,7 +327,7 @@ TEST_F(ReportSenderTest, ErroredRequestCallsErrorCallback) { ...@@ -341,7 +327,7 @@ TEST_F(ReportSenderTest, ErroredRequestCallsErrorCallback) {
bool error_callback_called = false; bool error_callback_called = false;
bool success_callback_called = false; bool success_callback_called = false;
const GURL url = URLRequestFailedJob::GetMockHttpsUrl(ERR_FAILED); const GURL url = URLRequestFailedJob::GetMockHttpsUrl(ERR_FAILED);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
// SendReport will block until the URLRequest is destroyed. // SendReport will block until the URLRequest is destroyed.
SendReport(&reporter, kDummyReport, url, 0, SendReport(&reporter, kDummyReport, url, 0,
base::Bind(SuccessCallback, &success_callback_called), base::Bind(SuccessCallback, &success_callback_called),
...@@ -357,7 +343,7 @@ TEST_F(ReportSenderTest, BadResponseCodeCallsErrorCallback) { ...@@ -357,7 +343,7 @@ TEST_F(ReportSenderTest, BadResponseCodeCallsErrorCallback) {
bool error_callback_called = false; bool error_callback_called = false;
bool success_callback_called = false; bool success_callback_called = false;
const GURL url(std::string("http://") + kServerErrorHostname); const GURL url(std::string("http://") + kServerErrorHostname);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
// SendReport will block until the URLRequest is destroyed. // SendReport will block until the URLRequest is destroyed.
SendReport(&reporter, kDummyReport, url, 0, SendReport(&reporter, kDummyReport, url, 0,
base::Bind(SuccessCallback, &success_callback_called), base::Bind(SuccessCallback, &success_callback_called),
...@@ -372,7 +358,7 @@ TEST_F(ReportSenderTest, SuccessfulRequestCallsSuccessCallback) { ...@@ -372,7 +358,7 @@ TEST_F(ReportSenderTest, SuccessfulRequestCallsSuccessCallback) {
bool error_callback_called = false; bool error_callback_called = false;
bool success_callback_called = false; bool success_callback_called = false;
const GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1); const GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES); ReportSender reporter(context());
SendReport(&reporter, kDummyReport, url, 0, SendReport(&reporter, kDummyReport, url, 0,
base::Bind(SuccessCallback, &success_callback_called), base::Bind(SuccessCallback, &success_callback_called),
base::Bind(ErrorCallback, &error_callback_called)); base::Bind(ErrorCallback, &error_callback_called));
...@@ -380,24 +366,5 @@ TEST_F(ReportSenderTest, SuccessfulRequestCallsSuccessCallback) { ...@@ -380,24 +366,5 @@ TEST_F(ReportSenderTest, SuccessfulRequestCallsSuccessCallback) {
EXPECT_TRUE(success_callback_called); EXPECT_TRUE(success_callback_called);
} }
// Test that cookies are sent or not sent according to the error
// reporter's cookies preference.
TEST_F(ReportSenderTest, SendCookiesPreference) {
GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1);
ReportSender reporter(context(), ReportSender::SEND_COOKIES);
network_delegate_.set_expect_cookies(true);
SendReport(&reporter, kDummyReport, url, 0);
}
TEST_F(ReportSenderTest, DoNotSendCookiesPreference) {
GURL url = URLRequestMockDataJob::GetMockHttpsUrl("dummy data", 1);
ReportSender reporter(context(), ReportSender::DO_NOT_SEND_COOKIES);
network_delegate_.set_expect_cookies(false);
SendReport(&reporter, kDummyReport, url, 0);
}
} // namespace } // namespace
} // namespace net } // namespace net
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment