Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / modules / push_messaging / PushError.h
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef PushError_h
6 #define PushError_h
7
8 #include "core/dom/DOMError.h"
9 #include "platform/heap/Handle.h"
10 #include "public/platform/WebPushError.h"
11 #include "wtf/OwnPtr.h"
12
13 namespace WebCore {
14
15 class ScriptPromiseResolverWithContext;
16
17 class PushError {
18     WTF_MAKE_NONCOPYABLE(PushError);
19 public:
20     // For CallbackPromiseAdapter.
21     typedef blink::WebPushError WebType;
22     static PassRefPtrWillBeRawPtr<DOMError> from(ScriptPromiseResolverWithContext*, WebType* webErrorRaw)
23     {
24         OwnPtr<WebType> webError = adoptPtr(webErrorRaw);
25         RefPtrWillBeRawPtr<DOMError> error = DOMError::create(errorString(webError->errorType), webError->message);
26         return error.release();
27     }
28
29 private:
30     static String errorString(blink::WebPushError::ErrorType);
31
32     PushError() WTF_DELETED_FUNCTION;
33 };
34
35 } // namespace WebCore
36
37 #endif // PushError_h