-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfeedback_service_interface.h
71 lines (59 loc) · 2.13 KB
/
feedback_service_interface.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright 2014 The Chromium OS 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 FEEDBACK_FEEDBACK_SERVICE_INTERFACE_H_
#define FEEDBACK_FEEDBACK_SERVICE_INTERFACE_H_
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "dbus/bus.h"
#include "dbus/message.h"
namespace base {
class Thread;
}
class FeedbackCommon;
typedef base::Callback<void(bool status)>
FeedbackResultCallback;
class FeedbackServiceInterface :
public base::RefCountedThreadSafe<FeedbackServiceInterface> {
public:
// Attempt to send the provided feedback report. If the report is invalid
// (empty description or product ID of 0) then false will be returned.
// Otherwise, this will return true and the provided callback
// will be called with true if the report is successfully sent, or queued
// for later upload, and false if there was an error talking to the
// feedback service daemon.
virtual bool SendFeedback(
const FeedbackCommon& feedback,
FeedbackResultCallback callback) = 0;
protected:
friend class base::RefCountedThreadSafe<FeedbackServiceInterface>;
virtual ~FeedbackServiceInterface() {}
};
// Sending feedback example
// void some_callback(bool success) {}
//
// base::Thread thread("Feedback DBus thread");
// base::Thread::Options opts(base::MessageLoop::TYPE_IO, 0);
// thread.StartWithOptions(opts);
// DBusFeedbackServiceInterface service(&thread);
// FeedbackCommon feedback;
// feedback.set_user_email(...)
// feedback.set_description(...)
// ...
// feedback.AddFile(attachment_name, attachment_data);
// ...
// feedback.AddLog(log_name, log_data);
// ...
// feedback.CompressLogs();
// service.SendFeedback(feedback, base::Bind(&some_callback))
class DBusFeedbackServiceInterface : public FeedbackServiceInterface {
public:
DBusFeedbackServiceInterface();
bool SendFeedback(
const FeedbackCommon& feedback,
FeedbackResultCallback callback) override;
private:
scoped_refptr<dbus::Bus> bus_;
DISALLOW_COPY_AND_ASSIGN(DBusFeedbackServiceInterface);
};
#endif // FEEDBACK_FEEDBACK_SERVICE_INTERFACE_H_