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

Side by Side Diff: chrome/browser/feedback/feedback_profile_observer.cc

Issue 141433011: Cache feedback reports to disk in case of send failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
Zachary Kuznia 2014/01/23 05:21:01 2014
rkc 2014/01/23 21:48:00 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/feedback/feedback_profile_observer.h"
6
7 #include "base/callback.h"
8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/feedback/feedback_report.h"
10 #include "chrome/browser/feedback/feedback_uploader.h"
11 #include "chrome/browser/feedback/feedback_uploader_factory.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/browser_context.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_service.h"
16
17 using content::BrowserThread;
18
19 namespace {
20
21 static base::LazyInstance<feedback::FeedbackProfileObserver>::Leaky
22 g_feedback_profile_observer = LAZY_INSTANCE_INITIALIZER;
23
24 }
25
26 namespace feedback {
27
28 // static
29 void FeedbackProfileObserver::Initialize() {
30 g_feedback_profile_observer.Get();
31 }
32
33 FeedbackProfileObserver::FeedbackProfileObserver() {
34 prefs_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED,
35 content::NotificationService::AllSources());
36 }
37
38 FeedbackProfileObserver::~FeedbackProfileObserver() {
39 prefs_registrar_.RemoveAll();
40 }
41
42 void FeedbackProfileObserver::Observe(
43 int type,
44 const content::NotificationSource& source,
45 const content::NotificationDetails& details) {
46 switch (type) {
47 case chrome::NOTIFICATION_PROFILE_CREATED: {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49 Profile* profile = content::Source<Profile>(source).ptr();
50 if (!profile->IsOffTheRecord())
51 QueueUnsentReports(profile);
52 break;
53 }
54 default:
55 NOTREACHED();
56 }
57 }
58
59 void FeedbackProfileObserver::QueueUnsentReports(
60 content::BrowserContext* context) {
61 feedback::FeedbackUploader *uploader =
62 feedback::FeedbackUploaderFactory::GetForBrowserContext(context);
63 BrowserThread::PostBlockingPoolTask(FROM_HERE,
64 base::Bind(
65 &FeedbackReport::LoadReportsAndQueue, context, base::Bind(
66 &FeedbackUploader::QueueReport, uploader->AsWeakPtr())));
67 }
68
69 } // namespace feedback
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698