Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Side by Side Diff: extensions/renderer/object_backed_native_handler.h

Issue 1167423002: Use V8 Maybe APIs in extensions/renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ 5 #ifndef EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_
6 #define EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ 6 #define EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "extensions/renderer/native_handler.h" 13 #include "extensions/renderer/native_handler.h"
14 #include "v8/include/v8-util.h" 14 #include "v8/include/v8-util.h"
15 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
16 16
17 namespace extensions { 17 namespace extensions {
18 class ScriptContext; 18 class ScriptContext;
19 19
20 // An ObjectBackedNativeHandler is a factory for JS objects with functions on 20 // An ObjectBackedNativeHandler is a factory for JS objects with functions on
21 // them that map to native C++ functions. Subclasses should call RouteFunction() 21 // them that map to native C++ functions. Subclasses should call RouteFunction()
22 // in their constructor to define functions on the created JS objects. 22 // in their constructor to define functions on the created JS objects.
23 class ObjectBackedNativeHandler : public NativeHandler { 23 class ObjectBackedNativeHandler : public NativeHandler {
24 public: 24 public:
25 explicit ObjectBackedNativeHandler(ScriptContext* context); 25 explicit ObjectBackedNativeHandler(ScriptContext* context);
26 ~ObjectBackedNativeHandler() override; 26 ~ObjectBackedNativeHandler() override;
27 27
28 // Create an object with bindings to the native functions defined through 28 // Create an object with bindings to the native functions defined through
29 // RouteFunction(). 29 // RouteFunction().
30 v8::Local<v8::Object> NewInstance() override; 30 v8::MaybeLocal<v8::Object> NewInstance() override;
31 31
32 v8::Isolate* GetIsolate() const; 32 v8::Isolate* GetIsolate() const;
33 33
34 protected: 34 protected:
35 typedef base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)> 35 typedef base::Callback<void(const v8::FunctionCallbackInfo<v8::Value>&)>
36 HandlerFunction; 36 HandlerFunction;
37 37
38 // Installs a new 'route' from |name| to |handler_function|. This means that 38 // Installs a new 'route' from |name| to |handler_function|. This means that
39 // NewInstance()s of this ObjectBackedNativeHandler will have a property 39 // NewInstance()s of this ObjectBackedNativeHandler will have a property
40 // |name| which will be handled by |handler_function|. 40 // |name| which will be handled by |handler_function|.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ScriptContext* context_; 73 ScriptContext* context_;
74 74
75 v8::Global<v8::ObjectTemplate> object_template_; 75 v8::Global<v8::ObjectTemplate> object_template_;
76 76
77 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler); 77 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler);
78 }; 78 };
79 79
80 } // namespace extensions 80 } // namespace extensions
81 81
82 #endif // EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_ 82 #endif // EXTENSIONS_RENDERER_OBJECT_BACKED_NATIVE_HANDLER_H_
OLDNEW
« no previous file with comments | « extensions/renderer/native_handler.h ('k') | extensions/renderer/object_backed_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698