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

Unified Diff: components/suggestions/image_manager.cc

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: All comments addressed. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/suggestions/image_manager.cc
diff --git a/components/suggestions/image_manager.cc b/components/suggestions/image_manager.cc
index 366a6a2018c8341130c37973c418c170cc7239cc..920a041f138d734228b0bb0ec59bb38ab9d31978 100644
--- a/components/suggestions/image_manager.cc
+++ b/components/suggestions/image_manager.cc
@@ -12,6 +12,7 @@
#include "base/task_runner_util.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "components/suggestions/image_encoder.h"
+#include "net/traffic_annotation/network_traffic_annotation.h"
#include "ui/gfx/image/image.h"
using leveldb_proto::ProtoDatabase;
@@ -39,6 +40,39 @@ void WrapCallback(
wrapped_callback.Run(GURL(url), image);
}
+constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =
+ net::DefineNetworkTrafficAnnotation("image_manager", R"(
Marc Treib 2017/05/09 13:40:36 nit: I don't know what this name is used for, but
Ramin Halavati 2017/05/09 13:57:50 Done.
+ semantics {
+ sender: "suggestions_service"
Marc Treib 2017/05/09 13:40:36 optional: This field seems to be a bit more verbos
Ramin Halavati 2017/05/09 13:57:50 Done.
+ description:
+ "Retrieves thumbnails for site suggestions based on the user's "
+ "synced browsing history, for use e.g. on the New Tab page."
+ trigger:
+ "Triggered when a thumbnail for a suggestion is required, and no "
+ "local thumbnail is available."
+ data: "The URL for which to retrieve a thumbnail."
+ destination: GOOGLE_OWNED_SERVICE
+ }
+ policy {
+ cookies_allowed: false
+ setting:
+ "Users can disable this feature by signing out of Chrome, or "
+ "disabling Sync or History Sync in Chrome settings under 'Advanced "
+ "sync settings...'. The feature is enabled by default."
+ chrome_policy {
+ SyncDisabled {
Marc Treib 2017/05/09 13:40:36 Also here: misaligned?
Ramin Halavati 2017/05/09 13:57:50 Done.
+ policy_options {mode: MANDATORY}
+ SyncDisabled: true
+ }
+ }
+ chrome_policy {
+ SigninAllowed {
+ policy_options {mode: MANDATORY}
+ SigninAllowed: false
+ }
+ }
+ })");
+
} // namespace
namespace suggestions {
@@ -146,7 +180,8 @@ void ImageManager::OnCacheImageDecoded(
callback.Run(url, gfx::Image::CreateFrom1xBitmap(*bitmap));
} else {
image_fetcher_->StartOrQueueNetworkRequest(
- url.spec(), image_url, base::Bind(&WrapCallback, callback));
+ url.spec(), image_url, base::Bind(&WrapCallback, callback),
+ kTrafficAnnotation);
}
}
@@ -173,7 +208,8 @@ void ImageManager::ServeFromCacheOrNetwork(
weak_ptr_factory_.GetWeakPtr(), url, image_url, callback));
} else {
image_fetcher_->StartOrQueueNetworkRequest(
- url.spec(), image_url, base::Bind(&WrapCallback, callback));
+ url.spec(), image_url, base::Bind(&WrapCallback, callback),
+ kTrafficAnnotation);
}
}

Powered by Google App Engine
This is Rietveld 408576698