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

Side by Side Diff: chrome/browser/search/thumbnail_source.cc

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: Annotation moved to callers. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/search/thumbnail_source.h" 5 #include "chrome/browser/search/thumbnail_source.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted_memory.h" 8 #include "base/memory/ref_counted_memory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_io_context.h" 10 #include "chrome/browser/search/instant_io_context.h"
11 #include "chrome/browser/thumbnails/thumbnail_service.h" 11 #include "chrome/browser/thumbnails/thumbnail_service.h"
12 #include "chrome/browser/thumbnails/thumbnail_service_factory.h" 12 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "net/traffic_annotation/network_traffic_annotation.h"
14 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
18 namespace {
19
20 constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation =
21 net::DefineNetworkTrafficAnnotation("...", R"(
Marc Treib 2017/05/09 09:43:47 thumbnail_source
Ramin Halavati 2017/05/09 11:08:24 Done.
22 semantics {
23 sender: "..."
Marc Treib 2017/05/09 09:43:47 ThumbnailSource
Ramin Halavati 2017/05/09 11:08:24 Done.
24 description: "..."
Marc Treib 2017/05/09 09:43:47 Retrieves thumbnails for site suggestions based on
Ramin Halavati 2017/05/09 11:08:24 Done.
25 trigger: "..."
Marc Treib 2017/05/09 09:43:47 Triggered when a thumbnail for a suggestion is req
Ramin Halavati 2017/05/09 11:08:24 Done.
26 data: "..."
Marc Treib 2017/05/09 09:43:47 None.
Ramin Halavati 2017/05/09 11:08:24 Doesn't it sent the URL to that thumbnail? Isn't i
Marc Treib 2017/05/09 11:38:34 Right, the request URL includes the URL of the pag
Ramin Halavati 2017/05/09 13:16:47 Done.
27 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER/LOCAL
Ramin Halavati 2017/05/09 11:08:24 GOOGLE_OWNED_SERVICE?
Marc Treib 2017/05/09 11:38:34 Yes. Sorry, missed that one.
Ramin Halavati 2017/05/09 13:16:47 Done.
28 }
29 policy {
30 cookies_allowed: false/true
Marc Treib 2017/05/09 09:43:47 false
Ramin Halavati 2017/05/09 11:08:24 Done.
31 cookies_store: "..."
32 setting: "..."
Marc Treib 2017/05/09 09:43:47 Same here: Cannot be disabled individually, but us
Ramin Halavati 2017/05/09 13:16:47 Done.
33 chrome_policy {
34 [POLICY_NAME] {
35 policy_options {mode: MANDATORY/RECOMMENDED/UNSET}
36 [POLICY_NAME]: ... //(value to disable it)
37 }
38 }
39 policy_exception_justification: "..."
40 })");
41
42 } // namespace
43
17 // The delimiter between the first url and the fallback url passed to 44 // The delimiter between the first url and the fallback url passed to
18 // StartDataRequest. 45 // StartDataRequest.
19 const char kUrlDelimiter[] = "?fb="; 46 const char kUrlDelimiter[] = "?fb=";
20 47
21 // Set ThumbnailService now as Profile isn't thread safe. 48 // Set ThumbnailService now as Profile isn't thread safe.
22 ThumbnailSource::ThumbnailSource(Profile* profile, bool capture_thumbnails) 49 ThumbnailSource::ThumbnailSource(Profile* profile, bool capture_thumbnails)
23 : thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)), 50 : thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)),
24 capture_thumbnails_(capture_thumbnails), 51 capture_thumbnails_(capture_thumbnails),
25 image_data_fetcher_(profile->GetRequestContext()), 52 image_data_fetcher_(profile->GetRequestContext(), kTrafficAnnotation),
26 weak_ptr_factory_(this) {} 53 weak_ptr_factory_(this) {}
27 54
28 ThumbnailSource::~ThumbnailSource() = default; 55 ThumbnailSource::~ThumbnailSource() = default;
29 56
30 std::string ThumbnailSource::GetSource() const { 57 std::string ThumbnailSource::GetSource() const {
31 return capture_thumbnails_ ? 58 return capture_thumbnails_ ?
32 chrome::kChromeUIThumbnailHost2 : chrome::kChromeUIThumbnailHost; 59 chrome::kChromeUIThumbnailHost2 : chrome::kChromeUIThumbnailHost;
33 } 60 }
34 61
35 void ThumbnailSource::StartDataRequest( 62 void ThumbnailSource::StartDataRequest(
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 const content::URLDataSource::GotDataCallback& callback, 143 const content::URLDataSource::GotDataCallback& callback,
117 const std::string& image_data, 144 const std::string& image_data,
118 const image_fetcher::RequestMetadata& metadata) { 145 const image_fetcher::RequestMetadata& metadata) {
119 if (image_data.empty()) { 146 if (image_data.empty()) {
120 callback.Run(nullptr); 147 callback.Run(nullptr);
121 return; 148 return;
122 } 149 }
123 std::string image_data_copy = image_data; 150 std::string image_data_copy = image_data;
124 callback.Run(base::RefCountedString::TakeString(&image_data_copy)); 151 callback.Run(base::RefCountedString::TakeString(&image_data_copy));
125 } 152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698