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

Side by Side Diff: components/offline_pages/core/offline_page_model_impl.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Created 3 years, 10 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 "components/offline_pages/core/offline_page_model_impl.h" 5 #include "components/offline_pages/core/offline_page_model_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 observers_.AddObserver(observer); 331 observers_.AddObserver(observer);
332 } 332 }
333 333
334 void OfflinePageModelImpl::RemoveObserver(Observer* observer) { 334 void OfflinePageModelImpl::RemoveObserver(Observer* observer) {
335 observers_.RemoveObserver(observer); 335 observers_.RemoveObserver(observer);
336 } 336 }
337 337
338 void OfflinePageModelImpl::SavePage( 338 void OfflinePageModelImpl::SavePage(
339 const SavePageParams& save_page_params, 339 const SavePageParams& save_page_params,
340 std::unique_ptr<OfflinePageArchiver> archiver, 340 std::unique_ptr<OfflinePageArchiver> archiver,
341 const std::vector<std::string>& signal_data,
341 const SavePageCallback& callback) { 342 const SavePageCallback& callback) {
342 DCHECK(is_loaded_); 343 DCHECK(is_loaded_);
343 344
344 // Skip saving the page that is not intended to be saved, like local file 345 // Skip saving the page that is not intended to be saved, like local file
345 // page. 346 // page.
346 if (!OfflinePageModel::CanSaveURL(save_page_params.url)) { 347 if (!OfflinePageModel::CanSaveURL(save_page_params.url)) {
347 InformSavePageDone(callback, SavePageResult::SKIPPED, 348 InformSavePageDone(callback, SavePageResult::SKIPPED,
348 save_page_params.client_id, kInvalidOfflineId); 349 save_page_params.client_id, kInvalidOfflineId);
349 return; 350 return;
350 } 351 }
351 352
352 // The web contents is not available if archiver is not created and passed. 353 // The web contents is not available if archiver is not created and passed.
353 if (!archiver.get()) { 354 if (!archiver.get()) {
354 InformSavePageDone(callback, SavePageResult::CONTENT_UNAVAILABLE, 355 InformSavePageDone(callback, SavePageResult::CONTENT_UNAVAILABLE,
355 save_page_params.client_id, kInvalidOfflineId); 356 save_page_params.client_id, kInvalidOfflineId);
356 return; 357 return;
357 } 358 }
358 359
359 // If we already have an offline id, use it. If not, generate one. 360 // If we already have an offline id, use it. If not, generate one.
360 int64_t offline_id = save_page_params.proposed_offline_id; 361 int64_t offline_id = save_page_params.proposed_offline_id;
361 if (offline_id == kInvalidOfflineId) 362 if (offline_id == kInvalidOfflineId)
362 offline_id = GenerateOfflineId(); 363 offline_id = GenerateOfflineId();
363 364
364 OfflinePageArchiver::CreateArchiveParams create_archive_params; 365 OfflinePageArchiver::CreateArchiveParams create_archive_params;
365 // If the page is being saved in the background, we should try to remove the 366 // If the page is being saved in the background, we should try to remove the
366 // popup overlay that obstructs viewing the normal content. 367 // popup overlay that obstructs viewing the normal content.
367 create_archive_params.remove_popup_overlay = save_page_params.is_background; 368 create_archive_params.remove_popup_overlay = save_page_params.is_background;
368 archiver->CreateArchive( 369 archiver->CreateArchive(
369 archives_dir_, create_archive_params, 370 archives_dir_, create_archive_params, signal_data,
370 base::Bind(&OfflinePageModelImpl::OnCreateArchiveDone, 371 base::Bind(&OfflinePageModelImpl::OnCreateArchiveDone,
371 weak_ptr_factory_.GetWeakPtr(), save_page_params, offline_id, 372 weak_ptr_factory_.GetWeakPtr(), save_page_params, offline_id,
372 GetCurrentTime(), callback)); 373 GetCurrentTime(), callback));
373 pending_archivers_.push_back(std::move(archiver)); 374 pending_archivers_.push_back(std::move(archiver));
374 } 375 }
375 376
376 void OfflinePageModelImpl::MarkPageAccessed(int64_t offline_id) { 377 void OfflinePageModelImpl::MarkPageAccessed(int64_t offline_id) {
377 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::MarkPageAccessedWhenLoadDone, 378 RunWhenLoaded(base::Bind(&OfflinePageModelImpl::MarkPageAccessedWhenLoadDone,
378 weak_ptr_factory_.GetWeakPtr(), offline_id)); 379 weak_ptr_factory_.GetWeakPtr(), offline_id));
379 } 380 }
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 } 1093 }
1093 1094
1094 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); 1095 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task);
1095 } 1096 }
1096 1097
1097 base::Time OfflinePageModelImpl::GetCurrentTime() const { 1098 base::Time OfflinePageModelImpl::GetCurrentTime() const {
1098 return testing_clock_ ? testing_clock_->Now() : base::Time::Now(); 1099 return testing_clock_ ? testing_clock_->Now() : base::Time::Now();
1099 } 1100 }
1100 1101
1101 } // namespace offline_pages 1102 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698