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

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

Issue 12693008: Prevent ObjectBackedNativeHandler from calling itself once invalid. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_ 5 #ifndef CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_
6 #define CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_ 6 #define CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 22 matching lines...) Expand all
33 typedef base::Callback<v8::Handle<v8::Value>(const v8::Arguments&)> 33 typedef base::Callback<v8::Handle<v8::Value>(const v8::Arguments&)>
34 HandlerFunction; 34 HandlerFunction;
35 35
36 // Installs a new 'route' from |name| to |handler_function|. This means that 36 // Installs a new 'route' from |name| to |handler_function|. This means that
37 // NewInstance()s of this ObjectBackedNativeHandler will have a property 37 // NewInstance()s of this ObjectBackedNativeHandler will have a property
38 // |name| which will be handled by |handler_function|. 38 // |name| which will be handled by |handler_function|.
39 void RouteFunction(const std::string& name, 39 void RouteFunction(const std::string& name,
40 const HandlerFunction& handler_function); 40 const HandlerFunction& handler_function);
41 41
42 void RouteStaticFunction(const std::string& name, 42 void RouteStaticFunction(const std::string& name,
43 const HandlerFunc handler_func); 43 const HandlerFunc& handler_func);
44 44
45 v8::Handle<v8::Context> v8_context() { return v8_context_.get(); } 45 v8::Handle<v8::Context> v8_context() { return v8_context_.get(); }
46 46
47 virtual void Invalidate() OVERRIDE; 47 virtual void Invalidate() OVERRIDE;
48 48
49 private: 49 private:
50
51 static v8::Handle<v8::Value> Router(const v8::Arguments& args); 50 static v8::Handle<v8::Value> Router(const v8::Arguments& args);
52 51
53 struct RouterData; 52 // Hold onto persistent handles for the router data we've created. Each is
54 std::vector<linked_ptr<RouterData> > router_data_; 53 // an object that contains an "is valid" flag along with a pointer to the
54 // method to call, if it's valid.
55 typedef std::vector<v8::Persistent<v8::Object> > RouterData;
56 RouterData router_data_;
55 57
56 // TODO(kalman): Just pass around a ChromeV8Context. It already has a 58 // TODO(kalman): Just pass around a ChromeV8Context. It already has a
57 // persistent handle to this context. 59 // persistent handle to this context.
58 ScopedPersistent<v8::Context> v8_context_; 60 ScopedPersistent<v8::Context> v8_context_;
59 61
60 ScopedPersistent<v8::ObjectTemplate> object_template_; 62 ScopedPersistent<v8::ObjectTemplate> object_template_;
61 63
62 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler); 64 DISALLOW_COPY_AND_ASSIGN(ObjectBackedNativeHandler);
63 }; 65 };
64 66
65 } // extensions 67 } // extensions
66 68
67 #endif // CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_ 69 #endif // CHROME_RENDERER_EXTENSIONS_OBJECT_BACKED_NATIVE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698