Commit 99985ec2 authored by rajendrant's avatar rajendrant Committed by Commit Bot

Add traffic annotation IDs for offline pages and downloads

Network traffic annotations are enforced in Windows, Linux. In other platforms
the annotation IDs are undefined. This leads to data use of android specific
services being bucketed to undefined bucket. This CL adds an annotation ID
for the codepath.

Bug: 762621
Change-Id: I5676680f3fb7c0f70cc1cd34ff36c898134990e7
Reviewed-on: https://chromium-review.googlesource.com/1128439Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarRyan Sleevi <rsleevi@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: rajendrant <rajendrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575029}
parent b6d74f81
...@@ -87,7 +87,8 @@ void CreateContextMenuDownload( ...@@ -87,7 +87,8 @@ void CreateContextMenuDownload(
web_contents->GetBrowserContext()); web_contents->GetBrowserContext());
std::unique_ptr<download::DownloadUrlParameters> dl_params( std::unique_ptr<download::DownloadUrlParameters> dl_params(
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame( content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
web_contents, url, NO_TRAFFIC_ANNOTATION_YET)); web_contents, url,
TRAFFIC_ANNOTATION_WITHOUT_PROTO("Download via context menu")));
content::Referrer referrer = content::Referrer::SanitizeForRequest( content::Referrer referrer = content::Referrer::SanitizeForRequest(
url, url,
content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy)); content::Referrer(referring_url.GetAsReferrer(), params.referrer_policy));
......
...@@ -75,5 +75,5 @@ static int JNI_AnswersImage_RequestAnswersImage( ...@@ -75,5 +75,5 @@ static int JNI_AnswersImage_RequestAnswersImage(
base::android::ConvertJavaStringToUTF8(env, java_url, &url); base::android::ConvertJavaStringToUTF8(env, java_url, &url);
return bitmap_fetcher_service->RequestImage( return bitmap_fetcher_service->RequestImage(
GURL(url), new AnswersImageObserverAndroid(env, java_callback), GURL(url), new AnswersImageObserverAndroid(env, java_callback),
NO_TRAFFIC_ANNOTATION_YET); TRAFFIC_ANNOTATION_WITHOUT_PROTO("Omnibox answers image"));
} }
...@@ -87,7 +87,8 @@ WebApkIconHasher::WebApkIconHasher( ...@@ -87,7 +87,8 @@ WebApkIconHasher::WebApkIconHasher(
auto resource_request = std::make_unique<network::ResourceRequest>(); auto resource_request = std::make_unique<network::ResourceRequest>();
resource_request->url = icon_url; resource_request->url = icon_url;
simple_url_loader_ = network::SimpleURLLoader::Create( simple_url_loader_ = network::SimpleURLLoader::Create(
std::move(resource_request), NO_TRAFFIC_ANNOTATION_YET); std::move(resource_request),
TRAFFIC_ANNOTATION_WITHOUT_PROTO("webapk icon hasher"));
simple_url_loader_->DownloadToStringOfUnboundedSizeUntilCrashAndDie( simple_url_loader_->DownloadToStringOfUnboundedSizeUntilCrashAndDie(
url_loader_factory, url_loader_factory,
base::BindOnce(&WebApkIconHasher::OnSimpleLoaderComplete, base::BindOnce(&WebApkIconHasher::OnSimpleLoaderComplete,
......
...@@ -237,7 +237,8 @@ void DownloadAsFile(content::WebContents* web_contents, const GURL& url) { ...@@ -237,7 +237,8 @@ void DownloadAsFile(content::WebContents* web_contents, const GURL& url) {
web_contents->GetBrowserContext()); web_contents->GetBrowserContext());
std::unique_ptr<download::DownloadUrlParameters> dl_params( std::unique_ptr<download::DownloadUrlParameters> dl_params(
content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame( content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame(
web_contents, url, NO_TRAFFIC_ANNOTATION_YET)); web_contents, url,
TRAFFIC_ANNOTATION_WITHOUT_PROTO("Offline pages download file")));
content::NavigationEntry* entry = content::NavigationEntry* entry =
web_contents->GetController().GetLastCommittedEntry(); web_contents->GetController().GetLastCommittedEntry();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_ #define NET_TRAFFIC_ANNOTATION_NETWORK_TRAFFIC_ANNOTATION_H_
#include "base/logging.h" #include "base/logging.h"
#include "build/build_config.h"
namespace { namespace {
...@@ -291,6 +292,11 @@ struct MutablePartialNetworkTrafficAnnotationTag { ...@@ -291,6 +292,11 @@ struct MutablePartialNetworkTrafficAnnotationTag {
} // namespace net } // namespace net
// Placeholder for unannotated usages. // Placeholder for unannotated usages.
#if !defined(OS_WIN) && !defined(OS_LINUX) && !defined(OS_CHROMEOS)
#define TRAFFIC_ANNOTATION_WITHOUT_PROTO(ANNOTATION_ID) \
net::DefineNetworkTrafficAnnotation(ANNOTATION_ID, "No proto yet.")
#endif
#define NO_TRAFFIC_ANNOTATION_YET \ #define NO_TRAFFIC_ANNOTATION_YET \
net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.") net::DefineNetworkTrafficAnnotation("undefined", "Nothing here yet.")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment