OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 EXTENSIONS_RENDERER_API_LAST_ERROR_H_ | |
6 #define EXTENSIONS_RENDERER_API_LAST_ERROR_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback.h" | |
11 #include "base/macros.h" | |
12 #include "v8/include/v8.h" | |
13 | |
14 namespace extensions { | |
15 | |
16 // Handles creating and clearing a 'lastError' property to hold the last error | |
17 // set by an extension API function. | |
18 class APILastError { | |
19 public: | |
20 // Returns the object the 'lastError' property should be exposed on for the | |
21 // given context. | |
22 using GetParent = | |
23 base::Callback<v8::Local<v8::Object>(v8::Local<v8::Context>)>; | |
24 | |
25 APILastError(const GetParent& get_parent); | |
jbroman
2017/02/13 19:41:27
explicit
Devlin
2017/02/14 04:57:08
Done.
| |
26 APILastError(APILastError&& other); | |
jbroman
2017/02/13 19:41:27
It's a little weird to have a move constructor wit
Devlin
2017/02/14 04:57:08
Right. Not sure if we have a preferred style here
| |
27 ~APILastError(); | |
28 | |
29 // Sets the last error for the given |context| to |error|. | |
30 void SetError(v8::Local<v8::Context> context, const std::string& error); | |
31 | |
32 // Clears the last error in the given |context|. If |report_if_unchecked| is | |
33 // true and the developer didn't check the error, this throws an exception. | |
34 void ClearError(v8::Local<v8::Context> context, bool report_if_unchecked); | |
35 | |
36 private: | |
37 GetParent get_parent_; | |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(APILastError); | |
40 }; | |
41 | |
42 } // namespace extensions | |
43 | |
44 #endif // EXTENSIONS_RENDERER_API_LAST_ERROR_H_ | |
OLD | NEW |