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

Side by Side Diff: chrome/renderer/weak_v8_function_map.h

Issue 8194005: Relanding: Add js api for hosted/packaged apps to request notification authorization (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« no previous file with comments | « chrome/renderer/extensions/extension_helper.cc ('k') | chrome/renderer/weak_v8_function_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 CHROME_RENDERER_WEAK_V8_FUNCTION_MAP_H_
6 #define CHROME_RENDERER_WEAK_V8_FUNCTION_MAP_H_
7 #pragma once
8
9 #include <map>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "v8/include/v8.h"
14
15 // This class lets you keep a mapping of integer to weak reference to a v8
16 // function. The entry will automatically get removed from the map if the
17 // function gets garbage collected.
18 class WeakV8FunctionMap {
19 public:
20 WeakV8FunctionMap();
21 ~WeakV8FunctionMap();
22
23 // Adds |callback_function| to the map under |key|. The entry will be removed
24 // from the map when the function is about to be GCed.
25 void Add(int key, v8::Local<v8::Function> callback_function);
26
27 // Removes and returns a entry from the map for |key|. If there was no entry
28 // for |key|, the return value will return true for IsEmpty().
29 v8::Persistent<v8::Function> Remove(int key);
30
31 private:
32 typedef std::map<int, v8::Persistent<v8::Function> > Map;
33 Map map_;
34 base::WeakPtrFactory<WeakV8FunctionMap> weak_ptr_factory_;
35
36 DISALLOW_COPY_AND_ASSIGN(WeakV8FunctionMap);
37 };
38
39 #endif // CHROME_RENDERER_WEAK_V8_FUNCTION_MAP_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/extension_helper.cc ('k') | chrome/renderer/weak_v8_function_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698