forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
web_push_common.h
51 lines (40 loc) · 1.64 KB
/
web_push_common.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
// Copyright 2019 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 COMPONENTS_GCM_DRIVER_WEB_PUSH_COMMON_H_
#define COMPONENTS_GCM_DRIVER_WEB_PUSH_COMMON_H_
#include <string>
#include "base/callback.h"
#include "base/optional.h"
namespace gcm {
// Result of sending web push message.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class SendWebPushMessageResult {
kSuccessful = 0,
kEncryptionFailed = 1,
kCreateJWTFailed = 2,
kNetworkError = 3,
kServerError = 4,
kParseResponseFailed = 5,
kVapidKeyInvalid = 6,
kDeviceGone = 7,
kPayloadTooLarge = 8,
kMaxValue = kPayloadTooLarge,
};
using WebPushCallback = base::OnceCallback<void(SendWebPushMessageResult,
base::Optional<std::string>)>;
// Invoke |callback| with |result| and logs the |result| to UMA. This should be
// called when after a web push message is sent. If |result| is
// SendWebPushMessageResult::Successful, |message_id| must be present.
void InvokeWebPushCallback(
WebPushCallback callback,
SendWebPushMessageResult result,
base::Optional<std::string> message_id = base::nullopt);
// Logs the size of message payload to UMA. This should be called right before a
// web push message is sent.
void LogSendWebPushMessagePayloadSize(int size);
// Logs the network error or status code after a web push message is sent.
void LogSendWebPushMessageStatusCode(int status_code);
} // namespace gcm
#endif // COMPONENTS_GCM_DRIVER_WEB_PUSH_COMMON_H_