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

Side by Side Diff: chrome/renderer/extensions/id_generator_custom_bindings.cc

Issue 235943018: Move extensions bindings code out of //chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 8 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
(Empty)
1 // Copyright 2013 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 #include "chrome/renderer/extensions/id_generator_custom_bindings.h"
6
7 #include "base/bind.h"
8 #include "grit/renderer_resources.h"
9 #include "v8/include/v8.h"
10
11 namespace extensions {
12
13 IdGeneratorCustomBindings::IdGeneratorCustomBindings(Dispatcher* dispatcher,
14 ChromeV8Context* context)
15 : ChromeV8Extension(dispatcher, context) {
16 RouteFunction("GetNextId", base::Bind(&IdGeneratorCustomBindings::GetNextId,
17 base::Unretained(this)));
18 }
19
20 void IdGeneratorCustomBindings::GetNextId(
21 const v8::FunctionCallbackInfo<v8::Value>& args) {
22 static int32_t next_id = 0;
23 ++next_id;
24 // Make sure 0 is never returned because some APIs (particularly WebRequest)
25 // have special meaning for 0 IDs.
26 if (next_id == 0)
27 next_id = 1;
28 args.GetReturnValue().Set(next_id);
29 }
30
31 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/id_generator_custom_bindings.h ('k') | chrome/renderer/extensions/logging_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698