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

Side by Side Diff: components/enhanced_bookmarks/bookmark_image_service.cc

Issue 476573004: Set version field when changes are made to enhanced bookmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Added flags TODO Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/enhanced_bookmarks/bookmark_image_service.h" 4 #include "components/enhanced_bookmarks/bookmark_image_service.h"
5 5
6 #include "base/single_thread_task_runner.h" 6 #include "base/single_thread_task_runner.h"
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "components/bookmarks/browser/bookmark_model.h" 9 #include "components/bookmarks/browser/bookmark_model.h"
10 #include "components/bookmarks/browser/bookmark_model_observer.h" 10 #include "components/bookmarks/browser/bookmark_model_observer.h"
11 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
11 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" 12 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h"
12 #include "components/enhanced_bookmarks/metadata_accessor.h"
13 #include "components/enhanced_bookmarks/persistent_image_store.h" 13 #include "components/enhanced_bookmarks/persistent_image_store.h"
14 14
15 namespace { 15 namespace {
16 16
17 const char kSequenceToken[] = "BookmarkImagesSequenceToken"; 17 const char kSequenceToken[] = "BookmarkImagesSequenceToken";
18 18
19 void ConstructPersistentImageStore(PersistentImageStore* store, 19 void ConstructPersistentImageStore(PersistentImageStore* store,
20 const base::FilePath& path) { 20 const base::FilePath& path) {
21 DCHECK(store); 21 DCHECK(store);
22 new (store) PersistentImageStore(path); 22 new (store) PersistentImageStore(path);
(...skipping 13 matching lines...) Expand all
36 origin_loop->PostTask( 36 origin_loop->PostTask(
37 FROM_HERE, base::Bind(callback, image_data.first, image_data.second)); 37 FROM_HERE, base::Bind(callback, image_data.first, image_data.second));
38 } 38 }
39 39
40 } // namespace 40 } // namespace
41 41
42 namespace enhanced_bookmarks { 42 namespace enhanced_bookmarks {
43 BookmarkImageService::BookmarkImageService( 43 BookmarkImageService::BookmarkImageService(
44 scoped_ptr<ImageStore> store, 44 scoped_ptr<ImageStore> store,
45 BookmarkModel* bookmark_model, 45 BookmarkModel* bookmark_model,
46 EnhancedBookmarkModel* enhanced_bookmark_model,
46 scoped_refptr<base::SequencedWorkerPool> pool) 47 scoped_refptr<base::SequencedWorkerPool> pool)
47 : bookmark_model_(bookmark_model), store_(store.Pass()), pool_(pool) { 48 : bookmark_model_(bookmark_model),
49 enhanced_bookmark_model_(enhanced_bookmark_model),
50 store_(store.Pass()),
51 pool_(pool) {
48 DCHECK(CalledOnValidThread()); 52 DCHECK(CalledOnValidThread());
49 bookmark_model_->AddObserver(this); 53 bookmark_model_->AddObserver(this);
50 } 54 }
51 55
52 BookmarkImageService::BookmarkImageService( 56 BookmarkImageService::BookmarkImageService(
53 const base::FilePath& path, 57 const base::FilePath& path,
54 BookmarkModel* bookmark_model, 58 BookmarkModel* bookmark_model,
59 EnhancedBookmarkModel* enhanced_bookmark_model,
55 scoped_refptr<base::SequencedWorkerPool> pool) 60 scoped_refptr<base::SequencedWorkerPool> pool)
56 : bookmark_model_(bookmark_model), pool_(pool) { 61 : bookmark_model_(bookmark_model),
62 enhanced_bookmark_model_(enhanced_bookmark_model),
63 pool_(pool) {
57 DCHECK(CalledOnValidThread()); 64 DCHECK(CalledOnValidThread());
58 // PersistentImageStore has to be constructed in the thread it will be used, 65 // PersistentImageStore has to be constructed in the thread it will be used,
59 // so we are posting the construction to the thread. However, we first 66 // so we are posting the construction to the thread. However, we first
60 // allocate memory and keep here. The reason is that, before 67 // allocate memory and keep here. The reason is that, before
61 // PersistentImageStore construction is done, it's possible that 68 // PersistentImageStore construction is done, it's possible that
62 // another member function, that posts store_ to the thread, is called. 69 // another member function, that posts store_ to the thread, is called.
63 // Although the construction might not be finished yet, we still want to post 70 // Although the construction might not be finished yet, we still want to post
64 // the task since it's guaranteed to be constructed by the time it is used, by 71 // the task since it's guaranteed to be constructed by the time it is used, by
65 // the sequential thread task pool. 72 // the sequential thread task pool.
66 // 73 //
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return; // A request for this URL is already in progress. 123 return; // A request for this URL is already in progress.
117 124
118 in_progress_page_urls_.insert(page_url); 125 in_progress_page_urls_.insert(page_url);
119 126
120 const BookmarkNode* bookmark = 127 const BookmarkNode* bookmark =
121 bookmark_model_->GetMostRecentlyAddedUserNodeForURL(page_url); 128 bookmark_model_->GetMostRecentlyAddedUserNodeForURL(page_url);
122 GURL image_url; 129 GURL image_url;
123 if (bookmark) { 130 if (bookmark) {
124 int width; 131 int width;
125 int height; 132 int height;
126 enhanced_bookmarks::ThumbnailImageFromBookmark( 133 enhanced_bookmark_model_->GetThumbnailImageForNode(
127 bookmark, &image_url, &width, &height); 134 bookmark, &image_url, &width, &height);
128 } 135 }
129 136
130 RetrieveSalientImage( 137 RetrieveSalientImage(
131 page_url, 138 page_url,
132 image_url, 139 image_url,
133 "", 140 "",
134 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE, 141 net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE,
135 false); 142 false);
136 } 143 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const GURL& image_url) { 191 const GURL& image_url) {
185 DCHECK(CalledOnValidThread()); 192 DCHECK(CalledOnValidThread());
186 StoreImage(image, image_url, page_url); 193 StoreImage(image, image_url, page_url);
187 in_progress_page_urls_.erase(page_url); 194 in_progress_page_urls_.erase(page_url);
188 ProcessRequests(page_url, image, image_url); 195 ProcessRequests(page_url, image, image_url);
189 if (update_bookmarks && image_url.is_valid()) { 196 if (update_bookmarks && image_url.is_valid()) {
190 const BookmarkNode* bookmark = 197 const BookmarkNode* bookmark =
191 bookmark_model_->GetMostRecentlyAddedUserNodeForURL(page_url); 198 bookmark_model_->GetMostRecentlyAddedUserNodeForURL(page_url);
192 if (bookmark) { 199 if (bookmark) {
193 const gfx::Size& size = image.Size(); 200 const gfx::Size& size = image.Size();
194 bool result = enhanced_bookmarks::SetOriginalImageForBookmark( 201 bool result = enhanced_bookmark_model_->SetOriginalImageForNode(
195 bookmark_model_, bookmark, image_url, size.width(), size.height()); 202 bookmark, image_url, size.width(), size.height(), false);
Yaron 2014/09/05 03:16:53 what does stars.userEdit mean? This can be as a re
Rune Fevang 2014/09/05 03:40:26 I don't understand the purpose of this field mysel
Mark 2014/09/08 22:47:08 The idea is that not all client edits are necessar
Yaron 2014/09/08 23:30:39 Sure, but then it should be true here which I see
196 DCHECK(result); 203 DCHECK(result);
197 } 204 }
198 } 205 }
199 } 206 }
200 207
201 bool BookmarkImageService::IsPageUrlInProgress(const GURL& page_url) { 208 bool BookmarkImageService::IsPageUrlInProgress(const GURL& page_url) {
202 DCHECK(CalledOnValidThread()); 209 DCHECK(CalledOnValidThread());
203 return in_progress_page_urls_.find(page_url) != in_progress_page_urls_.end(); 210 return in_progress_page_urls_.find(page_url) != in_progress_page_urls_.end();
204 } 211 }
205 212
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 const BookmarkNode* node) { 338 const BookmarkNode* node) {
332 } 339 }
333 340
334 void BookmarkImageService::BookmarkAllUserNodesRemoved( 341 void BookmarkImageService::BookmarkAllUserNodesRemoved(
335 BookmarkModel* model, 342 BookmarkModel* model,
336 const std::set<GURL>& removed_urls) { 343 const std::set<GURL>& removed_urls) {
337 ClearAll(); 344 ClearAll();
338 } 345 }
339 346
340 } // namespace enhanced_bookmarks 347 } // namespace enhanced_bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698