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

Side by Side Diff: components/offline_pages/offline_page_model.cc

Issue 1904613005: [Offline pages] Removing bookmarks dependency from offline pages component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests compilation Created 4 years, 8 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/offline_page_model.h" 5 #include "components/offline_pages/offline_page_model.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/metrics/histogram_macros.h" 14 #include "base/metrics/histogram_macros.h"
15 #include "base/rand_util.h" 15 #include "base/rand_util.h"
16 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "components/bookmarks/browser/bookmark_model.h"
21 #include "components/bookmarks/browser/bookmark_node.h"
22 #include "components/offline_pages/offline_page_item.h" 20 #include "components/offline_pages/offline_page_item.h"
23 #include "components/offline_pages/proto/offline_pages.pb.h" 21 #include "components/offline_pages/proto/offline_pages.pb.h"
24 #include "url/gurl.h" 22 #include "url/gurl.h"
25 23
26 using ArchiverResult = offline_pages::OfflinePageArchiver::ArchiverResult; 24 using ArchiverResult = offline_pages::OfflinePageArchiver::ArchiverResult;
27 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult; 25 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult;
28 26
29 namespace offline_pages { 27 namespace offline_pages {
30 28
31 namespace { 29 namespace {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 144
147 void OfflinePageModel::SavePage(const GURL& url, 145 void OfflinePageModel::SavePage(const GURL& url,
148 const ClientId& client_id, 146 const ClientId& client_id,
149 scoped_ptr<OfflinePageArchiver> archiver, 147 scoped_ptr<OfflinePageArchiver> archiver,
150 const SavePageCallback& callback) { 148 const SavePageCallback& callback) {
151 DCHECK(is_loaded_); 149 DCHECK(is_loaded_);
152 150
153 // Skip saving the page that is not intended to be saved, like local file 151 // Skip saving the page that is not intended to be saved, like local file
154 // page. 152 // page.
155 if (!CanSavePage(url)) { 153 if (!CanSavePage(url)) {
156 InformSavePageDone(callback, SavePageResult::SKIPPED, INVALID_OFFLINE_ID); 154 InformSavePageDone(callback, SavePageResult::SKIPPED, kInvalidOfflineId);
157 return; 155 return;
158 } 156 }
159 157
160 DCHECK(archiver.get()); 158 DCHECK(archiver.get());
161 159
162 int64_t offline_id = GenerateOfflineId(); 160 int64_t offline_id = GenerateOfflineId();
163 161
164 archiver->CreateArchive( 162 archiver->CreateArchive(
165 archives_dir_, 163 archives_dir_,
166 offline_id, 164 offline_id,
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) { 839 void OfflinePageModel::RunWhenLoaded(const base::Closure& task) {
842 if (!is_loaded_) { 840 if (!is_loaded_) {
843 delayed_tasks_.push_back(task); 841 delayed_tasks_.push_back(task);
844 return; 842 return;
845 } 843 }
846 844
847 task_runner_->PostTask(FROM_HERE, task); 845 task_runner_->PostTask(FROM_HERE, task);
848 } 846 }
849 847
850 } // namespace offline_pages 848 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_model.h ('k') | components/offline_pages/offline_page_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698