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

Side by Side Diff: components/sync_sessions/favicon_cache.cc

Issue 1549993003: Switch to standard integer types in components/, part 4 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/sync_sessions/favicon_cache.h" 5 #include "components/sync_sessions/favicon_cache.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/macros.h"
8 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 11 #include "base/thread_task_runner_handle.h"
11 #include "components/favicon/core/favicon_service.h" 12 #include "components/favicon/core/favicon_service.h"
12 #include "components/history/core/browser/history_service.h" 13 #include "components/history/core/browser/history_service.h"
13 #include "components/history/core/browser/history_types.h" 14 #include "components/history/core/browser/history_types.h"
14 #include "sync/api/time.h" 15 #include "sync/api/time.h"
15 #include "sync/protocol/favicon_image_specifics.pb.h" 16 #include "sync/protocol/favicon_image_specifics.pb.h"
16 #include "sync/protocol/favicon_tracking_specifics.pb.h" 17 #include "sync/protocol/favicon_tracking_specifics.pb.h"
17 #include "sync/protocol/sync.pb.h" 18 #include "sync/protocol/sync.pb.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 502
502 if (iter == page_favicon_map_.end()) 503 if (iter == page_favicon_map_.end())
503 return false; 504 return false;
504 505
505 return GetSyncedFaviconForFaviconURL(iter->second, favicon_png); 506 return GetSyncedFaviconForFaviconURL(iter->second, favicon_png);
506 } 507 }
507 508
508 void FaviconCache::OnReceivedSyncFavicon(const GURL& page_url, 509 void FaviconCache::OnReceivedSyncFavicon(const GURL& page_url,
509 const GURL& icon_url, 510 const GURL& icon_url,
510 const std::string& icon_bytes, 511 const std::string& icon_bytes,
511 int64 visit_time_ms) { 512 int64_t visit_time_ms) {
512 if (!icon_url.is_valid() || !page_url.is_valid() || icon_url.SchemeIs("data")) 513 if (!icon_url.is_valid() || !page_url.is_valid() || icon_url.SchemeIs("data"))
513 return; 514 return;
514 DVLOG(1) << "Associating " << page_url.spec() << " with favicon at " 515 DVLOG(1) << "Associating " << page_url.spec() << " with favicon at "
515 << icon_url.spec(); 516 << icon_url.spec();
516 page_favicon_map_[page_url] = icon_url; 517 page_favicon_map_[page_url] = icon_url;
517 518
518 // If there is no actual image, it means there either is no synced 519 // If there is no actual image, it means there either is no synced
519 // favicon, or it's on its way (race condition). 520 // favicon, or it's on its way (race condition).
520 // TODO(zea): potentially trigger a favicon web download here (delayed?). 521 // TODO(zea): potentially trigger a favicon web download here (delayed?).
521 if (icon_bytes.size() == 0) 522 if (icon_bytes.size() == 0)
522 return; 523 return;
523 524
524 // Post a task to do the actual association because this method may have been 525 // Post a task to do the actual association because this method may have been
525 // called while in a transaction. 526 // called while in a transaction.
526 base::ThreadTaskRunnerHandle::Get()->PostTask( 527 base::ThreadTaskRunnerHandle::Get()->PostTask(
527 FROM_HERE, base::Bind(&FaviconCache::OnReceivedSyncFaviconImpl, 528 FROM_HERE, base::Bind(&FaviconCache::OnReceivedSyncFaviconImpl,
528 weak_ptr_factory_.GetWeakPtr(), icon_url, 529 weak_ptr_factory_.GetWeakPtr(), icon_url,
529 icon_bytes, visit_time_ms)); 530 icon_bytes, visit_time_ms));
530 } 531 }
531 532
532 void FaviconCache::OnReceivedSyncFaviconImpl( 533 void FaviconCache::OnReceivedSyncFaviconImpl(const GURL& icon_url,
533 const GURL& icon_url, 534 const std::string& icon_bytes,
534 const std::string& icon_bytes, 535 int64_t visit_time_ms) {
535 int64 visit_time_ms) {
536 // If this favicon is already synced, do nothing else. 536 // If this favicon is already synced, do nothing else.
537 if (synced_favicons_.find(icon_url) != synced_favicons_.end()) 537 if (synced_favicons_.find(icon_url) != synced_favicons_.end())
538 return; 538 return;
539 539
540 // Don't add any more favicons once we hit our in memory limit. 540 // Don't add any more favicons once we hit our in memory limit.
541 // TODO(zea): UMA this. 541 // TODO(zea): UMA this.
542 if (kMaxFaviconsInMem != 0 && synced_favicons_.size() > kMaxFaviconsInMem) 542 if (kMaxFaviconsInMem != 0 && synced_favicons_.size() > kMaxFaviconsInMem)
543 return; 543 return;
544 544
545 SyncedFaviconInfo* favicon_info = GetFaviconInfo(icon_url); 545 SyncedFaviconInfo* favicon_info = GetFaviconInfo(icon_url);
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE, 1047 favicon_images_sync_processor_->ProcessSyncChanges(FROM_HERE,
1048 image_deletions); 1048 image_deletions);
1049 } 1049 }
1050 if (favicon_tracking_sync_processor_.get()) { 1050 if (favicon_tracking_sync_processor_.get()) {
1051 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE, 1051 favicon_tracking_sync_processor_->ProcessSyncChanges(FROM_HERE,
1052 tracking_deletions); 1052 tracking_deletions);
1053 } 1053 }
1054 } 1054 }
1055 1055
1056 } // namespace browser_sync 1056 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/sync_sessions/favicon_cache.h ('k') | components/sync_sessions/favicon_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698