summaryrefslogtreecommitdiff
path: root/Source/modules/push_messaging/PushError.h
blob: 667eb923afc706f613aa3ab8539df8994f928c3e (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
// 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 PushError_h
#define PushError_h

#include "core/dom/DOMError.h"
#include "heap/Handle.h"
#include "public/platform/WebPushError.h"
#include "wtf/OwnPtr.h"

namespace WebCore {

class PushError {
    WTF_MAKE_NONCOPYABLE(PushError);
public:
    // For CallbackPromiseAdapter.
    typedef blink::WebPushError WebType;
    static PassRefPtrWillBeRawPtr<DOMError> from(WebType* webErrorRaw)
    {
        OwnPtr<WebType> webError = adoptPtr(webErrorRaw);
        RefPtrWillBeRawPtr<DOMError> error = DOMError::create(errorString(webError->errorType), webError->message);
        return error.release();
    }

private:
    static String errorString(blink::WebPushError::ErrorType);

    PushError() WTF_DELETED_FUNCTION;
};

} // namespace WebCore

#endif // PushError_h