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

Side by Side Diff: chrome/browser/chromeos/hats/hats_notification_controller.cc

Issue 2794343002: Network traffic annotation added to image_data_fetcher. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/hats/hats_notification_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/chromeos/hats/hats_notification_controller.h" 5 #include "chrome/browser/chromeos/hats/hats_notification_controller.h"
6 6
7 #include "ash/strings/grit/ash_strings.h" 7 #include "ash/strings/grit/ash_strings.h"
8 #include "ash/system/system_notifier.h" 8 #include "ash/system/system_notifier.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/task_scheduler/post_task.h" 12 #include "base/task_scheduler/post_task.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chromeos/hats/hats_dialog.h" 14 #include "chrome/browser/chromeos/hats/hats_dialog.h"
15 #include "chrome/browser/chromeos/hats/hats_finch_helper.h" 15 #include "chrome/browser/chromeos/hats/hats_finch_helper.h"
16 #include "chrome/browser/chromeos/login/startup_utils.h" 16 #include "chrome/browser/chromeos/login/startup_utils.h"
17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 17 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" 18 #include "chrome/browser/chromeos/profiles/profile_helper.h"
19 #include "chrome/browser/notifications/notification_ui_manager.h" 19 #include "chrome/browser/notifications/notification_ui_manager.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/search/suggestions/image_decoder_impl.h" 21 #include "chrome/browser/search/suggestions/image_decoder_impl.h"
22 #include "chrome/common/chrome_features.h" 22 #include "chrome/common/chrome_features.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/grit/theme_resources.h" 24 #include "chrome/grit/theme_resources.h"
25 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
26 #include "chromeos/network/network_state.h" 26 #include "chromeos/network/network_state.h"
27 #include "components/image_fetcher/core/image_fetcher_impl.h" 27 #include "components/image_fetcher/core/image_fetcher_impl.h"
28 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
29 #include "net/traffic_annotation/network_traffic_annotation.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 31 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/gfx/image/image_skia_rep.h" 32 #include "ui/gfx/image/image_skia_rep.h"
32 #include "ui/message_center/message_center.h" 33 #include "ui/message_center/message_center.h"
33 #include "ui/message_center/notification_types.h" 34 #include "ui/message_center/notification_types.h"
34 #include "ui/strings/grit/ui_strings.h" 35 #include "ui/strings/grit/ui_strings.h"
35 36
36 namespace { 37 namespace {
37 38
38 const char kNotificationOriginUrl[] = "chrome://hats"; 39 const char kNotificationOriginUrl[] = "chrome://hats";
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (!image_fetcher_) 228 if (!image_fetcher_)
228 image_fetcher_.reset(new image_fetcher::ImageFetcherImpl( 229 image_fetcher_.reset(new image_fetcher::ImageFetcherImpl(
229 base::MakeUnique<suggestions::ImageDecoderImpl>(), 230 base::MakeUnique<suggestions::ImageDecoderImpl>(),
230 profile_->GetRequestContext())); 231 profile_->GetRequestContext()));
231 232
232 completed_requests_ = 0; 233 completed_requests_ = 0;
233 234
234 image_fetcher_->StartOrQueueNetworkRequest( 235 image_fetcher_->StartOrQueueNetworkRequest(
235 kImageFetcher1xId, GURL(kGoogleIcon1xUrl), 236 kImageFetcher1xId, GURL(kGoogleIcon1xUrl),
236 base::Bind(&HatsNotificationController::OnImageFetched, 237 base::Bind(&HatsNotificationController::OnImageFetched,
237 weak_pointer_factory_.GetWeakPtr())); 238 weak_pointer_factory_.GetWeakPtr()),
239 NO_TRAFFIC_ANNOTATION_YET);
238 image_fetcher_->StartOrQueueNetworkRequest( 240 image_fetcher_->StartOrQueueNetworkRequest(
239 kImageFetcher2xId, GURL(kGoogleIcon2xUrl), 241 kImageFetcher2xId, GURL(kGoogleIcon2xUrl),
240 base::Bind(&HatsNotificationController::OnImageFetched, 242 base::Bind(&HatsNotificationController::OnImageFetched,
241 weak_pointer_factory_.GetWeakPtr())); 243 weak_pointer_factory_.GetWeakPtr()),
244 NO_TRAFFIC_ANNOTATION_YET);
242 } 245 }
243 246
244 void HatsNotificationController::OnImageFetched( 247 void HatsNotificationController::OnImageFetched(
245 const std::string& id, 248 const std::string& id,
246 const gfx::Image& image, 249 const gfx::Image& image,
247 const image_fetcher::RequestMetadata& metadata) { 250 const image_fetcher::RequestMetadata& metadata) {
248 DCHECK(id == kImageFetcher1xId || id == kImageFetcher2xId); 251 DCHECK(id == kImageFetcher1xId || id == kImageFetcher2xId);
249 252
250 completed_requests_++; 253 completed_requests_++;
251 if (!image.IsEmpty()) { 254 if (!image.IsEmpty()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 GURL(kNotificationOriginUrl), kNotificationId, optional, this); 286 GURL(kNotificationOriginUrl), kNotificationId, optional, this);
284 } 287 }
285 288
286 void HatsNotificationController::UpdateLastInteractionTime() { 289 void HatsNotificationController::UpdateLastInteractionTime() {
287 PrefService* pref_service = profile_->GetPrefs(); 290 PrefService* pref_service = profile_->GetPrefs();
288 pref_service->SetInt64(prefs::kHatsLastInteractionTimestamp, 291 pref_service->SetInt64(prefs::kHatsLastInteractionTimestamp,
289 base::Time::Now().ToInternalValue()); 292 base::Time::Now().ToInternalValue());
290 } 293 }
291 294
292 } // namespace chromeos 295 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/hats/hats_notification_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698