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

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

Issue 2722463006: [Extensions Bindings] Notify of event unregistration on invalidation (Closed)
Patch Set: . Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_API_EVENT_HANDLER_H_ 5 #ifndef EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 6 #define EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 30 matching lines...) Expand all
41 // Notifies all listeners of the event with the given |event_name| in the 41 // Notifies all listeners of the event with the given |event_name| in the
42 // specified |context|, sending the included |arguments|. 42 // specified |context|, sending the included |arguments|.
43 void FireEventInContext(const std::string& event_name, 43 void FireEventInContext(const std::string& event_name,
44 v8::Local<v8::Context> context, 44 v8::Local<v8::Context> context,
45 const base::ListValue& arguments); 45 const base::ListValue& arguments);
46 46
47 // Returns the EventListeners for a given |event_name| and |context|. 47 // Returns the EventListeners for a given |event_name| and |context|.
48 size_t GetNumEventListenersForTesting(const std::string& event_name, 48 size_t GetNumEventListenersForTesting(const std::string& event_name,
49 v8::Local<v8::Context> context); 49 v8::Local<v8::Context> context);
50 50
51 // Invalidates listeners for the given |context|. It's a shame we have to
52 // have this separately (as opposed to hooking into e.g. a PerContextData
53 // destructor), but we need to do this before the context is fully removed.
jbroman 2017/03/01 17:49:47 Because it's gone from the ScriptContextSet, right
Devlin 2017/03/01 19:03:50 Correct (and the ScriptContext wrapper is deleted)
54 void InvalidateContext(v8::Local<v8::Context> context);
55
51 private: 56 private:
52 // Method to run a given v8::Function. Curried in for testing. 57 // Method to run a given v8::Function. Curried in for testing.
53 binding::RunJSFunction call_js_; 58 binding::RunJSFunction call_js_;
54 59
55 EventListenersChangedMethod listeners_changed_; 60 EventListenersChangedMethod listeners_changed_;
56 61
57 DISALLOW_COPY_AND_ASSIGN(APIEventHandler); 62 DISALLOW_COPY_AND_ASSIGN(APIEventHandler);
58 }; 63 };
59 64
60 } // namespace extensions 65 } // namespace extensions
61 66
62 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_ 67 #endif // EXTENSIONS_RENDERER_API_EVENT_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698