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

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_request_job_unittest.cc

Issue 2264903003: Adjust callers and networking delegates in chrome/ to modified APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@URLRequestRead
Patch Set: rebased Created 4 years, 3 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/android/offline_pages/offline_page_request_job.h" 5 #include "chrome/browser/android/offline_pages/offline_page_request_job.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/feature_list.h" 8 #include "base/feature_list.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 }; 94 };
95 95
96 class TestURLRequestDelegate : public net::URLRequest::Delegate { 96 class TestURLRequestDelegate : public net::URLRequest::Delegate {
97 public: 97 public:
98 typedef base::Callback<void(int)> ReadCompletedCallback; 98 typedef base::Callback<void(int)> ReadCompletedCallback;
99 99
100 explicit TestURLRequestDelegate(const ReadCompletedCallback& callback) 100 explicit TestURLRequestDelegate(const ReadCompletedCallback& callback)
101 : read_completed_callback_(callback), 101 : read_completed_callback_(callback),
102 buffer_(new net::IOBuffer(kBufSize)) {} 102 buffer_(new net::IOBuffer(kBufSize)) {}
103 103
104 void OnResponseStarted(net::URLRequest* request) override { 104 void OnResponseStarted(net::URLRequest* request, int net_error) override {
105 if (!request->status().is_success()) { 105 DCHECK_NE(net::ERR_IO_PENDING, net_error);
dewittj 2016/09/22 16:27:06 This DCHECK seems wrong. I can see two cases here
maksims (do not use this acc) 2016/09/29 12:43:14 Actually, IO_PENDING must not arrive here. It's ju
106 if (net_error != net::OK) {
106 read_completed_callback_.Run(0); 107 read_completed_callback_.Run(0);
107 return; 108 return;
108 } 109 }
109 int bytes_read = 0; 110 int bytes_read = 0;
110 request->Read(buffer_.get(), kBufSize, &bytes_read); 111 request->Read(buffer_.get(), kBufSize, &bytes_read);
111 } 112 }
112 113
113 void OnReadCompleted(net::URLRequest* request, int bytes_read) override { 114 void OnReadCompleted(net::URLRequest* request, int bytes_read) override {
114 if (!read_completed_callback_.is_null()) 115 if (!read_completed_callback_.is_null())
115 read_completed_callback_.Run(bytes_read); 116 read_completed_callback_.Run(bytes_read);
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 base::RunLoop().Run(); 757 base::RunLoop().Run();
757 758
758 EXPECT_EQ(0, bytes_read()); 759 EXPECT_EQ(0, bytes_read());
759 EXPECT_FALSE(offline_page_tab_helper()->GetOfflinePageForTest()); 760 EXPECT_FALSE(offline_page_tab_helper()->GetOfflinePageForTest());
760 ExpectAggregatedRequestResultHistogram( 761 ExpectAggregatedRequestResultHistogram(
761 OfflinePageRequestJob::AggregatedRequestResult:: 762 OfflinePageRequestJob::AggregatedRequestResult::
762 PAGE_NOT_FOUND_ON_CONNECTED_NETWORK); 763 PAGE_NOT_FOUND_ON_CONNECTED_NETWORK);
763 } 764 }
764 765
765 } // namespace offline_pages 766 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698