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

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

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Approach for writing to the file afterwards instead. Created 3 years, 9 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 int64_t offline_id2() const { return offline_id2_; } 281 int64_t offline_id2() const { return offline_id2_; }
282 int64_t offline_id3() const { return offline_id3_; } 282 int64_t offline_id3() const { return offline_id3_; }
283 int64_t offline_id4() const { return offline_id4_; } 283 int64_t offline_id4() const { return offline_id4_; }
284 int bytes_read() const { return bytes_read_; } 284 int bytes_read() const { return bytes_read_; }
285 285
286 TestPreviewsDecider* test_previews_decider() { 286 TestPreviewsDecider* test_previews_decider() {
287 return test_previews_decider_.get(); 287 return test_previews_decider_.get();
288 } 288 }
289 289
290 private: 290 private:
291 void OnSavePageDone(SavePageResult result, int64_t offline_id); 291 void OnSavePageDone(SavePageResult result,
292 int64_t offline_id,
293 const base::FilePath& saved_filepath);
292 std::unique_ptr<net::URLRequest> CreateRequest( 294 std::unique_ptr<net::URLRequest> CreateRequest(
293 const GURL& url, 295 const GURL& url,
294 const std::string& method, 296 const std::string& method,
295 content::ResourceType resource_type); 297 content::ResourceType resource_type);
296 void ReadCompleted(int bytes_read); 298 void ReadCompleted(int bytes_read);
297 299
298 // Runs on IO thread. 300 // Runs on IO thread.
299 void InterceptRequestOnIO(const GURL& url, 301 void InterceptRequestOnIO(const GURL& url,
300 const std::string& method, 302 const std::string& method,
301 const std::string& extra_header_name, 303 const std::string& extra_header_name,
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 save_page_params.client_id = client_id; 508 save_page_params.client_id = client_id;
507 save_page_params.original_url = original_url; 509 save_page_params.original_url = original_url;
508 OfflinePageModelFactory::GetForBrowserContext(profile())->SavePage( 510 OfflinePageModelFactory::GetForBrowserContext(profile())->SavePage(
509 save_page_params, 511 save_page_params,
510 std::move(archiver), 512 std::move(archiver),
511 base::Bind(&OfflinePageRequestJobTest::OnSavePageDone, 513 base::Bind(&OfflinePageRequestJobTest::OnSavePageDone,
512 base::Unretained(this))); 514 base::Unretained(this)));
513 RunUntilIdle(); 515 RunUntilIdle();
514 } 516 }
515 517
516 void OfflinePageRequestJobTest::OnSavePageDone(SavePageResult result, 518 void OfflinePageRequestJobTest::OnSavePageDone(
517 int64_t offline_id) { 519 SavePageResult result,
520 int64_t offline_id,
521 const base::FilePath& saved_filepath) {
518 ASSERT_EQ(SavePageResult::SUCCESS, result); 522 ASSERT_EQ(SavePageResult::SUCCESS, result);
519 if (offline_id_ == -1) 523 if (offline_id_ == -1)
520 offline_id_ = offline_id; 524 offline_id_ = offline_id;
521 else if (offline_id2_ == -1) 525 else if (offline_id2_ == -1)
522 offline_id2_ = offline_id; 526 offline_id2_ = offline_id;
523 else if (offline_id3_ == -1) 527 else if (offline_id3_ == -1)
524 offline_id3_ = offline_id; 528 offline_id3_ = offline_id;
525 else if (offline_id4_ == -1) 529 else if (offline_id4_ == -1)
526 offline_id4_ = offline_id; 530 offline_id4_ = offline_id;
527 } 531 }
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 ASSERT_TRUE(offline_page_tab_helper()->GetOfflinePageForTest()); 901 ASSERT_TRUE(offline_page_tab_helper()->GetOfflinePageForTest());
898 EXPECT_EQ(offline_id4(), 902 EXPECT_EQ(offline_id4(),
899 offline_page_tab_helper()->GetOfflinePageForTest()->offline_id); 903 offline_page_tab_helper()->GetOfflinePageForTest()->offline_id);
900 ExpectOneUniqueSampleForAggregatedRequestResult( 904 ExpectOneUniqueSampleForAggregatedRequestResult(
901 OfflinePageRequestJob::AggregatedRequestResult:: 905 OfflinePageRequestJob::AggregatedRequestResult::
902 SHOW_OFFLINE_ON_DISCONNECTED_NETWORK); 906 SHOW_OFFLINE_ON_DISCONNECTED_NETWORK);
903 ExpectOpenFileErrorCode(net::ERR_FILE_NOT_FOUND); 907 ExpectOpenFileErrorCode(net::ERR_FILE_NOT_FOUND);
904 } 908 }
905 909
906 } // namespace offline_pages 910 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698