summaryrefslogtreecommitdiffstats
path: root/chrome/browser/feedback/feedback_profile_observer.h
blob: fe8519544c6a435eaa886358d7e6a55cc7a00e16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_FEEDBACK_FEEDBACK_PROFILE_OBSERVER_H_
#define CHROME_BROWSER_FEEDBACK_FEEDBACK_PROFILE_OBSERVER_H_

#include "base/basictypes.h"
#include "base/lazy_instance.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"

namespace content {
class BrowserContext;
}

namespace feedback {

class FeedbackUploader;

// FeedbackProfileObserver waits on profile creation notifications to check
// if the profile has any pending feedback reports to upload. If it does, it
// queues those reports for upload.
class FeedbackProfileObserver : public content::NotificationObserver {
 public:
  static void Initialize();

 private:
  friend struct base::DefaultLazyInstanceTraits<FeedbackProfileObserver>;

  FeedbackProfileObserver();
  ~FeedbackProfileObserver() override;

  // content::NotificationObserver override
  void Observe(int type,
               const content::NotificationSource& source,
               const content::NotificationDetails& details) override;

  // Loads any unsent reports from disk and queues them to be uploaded in
  // the given browser context.
  void QueueUnsentReports(content::BrowserContext* context);

  static void QueueSingleReport(feedback::FeedbackUploader* uploader,
                                const std::string& data);

  // Used to track creation of profiles so we can load any unsent reports
  // for that profile.
  content::NotificationRegistrar prefs_registrar_;

  DISALLOW_COPY_AND_ASSIGN(FeedbackProfileObserver);
};

}  // namespace feedback

#endif  // CHROME_BROWSER_FEEDBACK_FEEDBACK_PROFILE_OBSERVER_H_