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

Side by Side Diff: extensions/renderer/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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 #include "chrome/renderer/extensions/id_generator_custom_bindings.h" 5 #include "extensions/renderer/id_generator_custom_bindings.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "grit/renderer_resources.h"
9 #include "v8/include/v8.h"
10 8
11 namespace extensions { 9 namespace extensions {
12 10
13 IdGeneratorCustomBindings::IdGeneratorCustomBindings(Dispatcher* dispatcher, 11 IdGeneratorCustomBindings::IdGeneratorCustomBindings(ScriptContext* context)
14 ChromeV8Context* context) 12 : ObjectBackedNativeHandler(context) {
15 : ChromeV8Extension(dispatcher, context) { 13 RouteFunction("GetNextId",
16 RouteFunction("GetNextId", base::Bind(&IdGeneratorCustomBindings::GetNextId, 14 base::Bind(&IdGeneratorCustomBindings::GetNextId,
17 base::Unretained(this))); 15 base::Unretained(this)));
18 } 16 }
19 17
20 void IdGeneratorCustomBindings::GetNextId( 18 void IdGeneratorCustomBindings::GetNextId(
21 const v8::FunctionCallbackInfo<v8::Value>& args) { 19 const v8::FunctionCallbackInfo<v8::Value>& args) {
22 static int32_t next_id = 0; 20 static int32_t next_id = 0;
23 ++next_id; 21 ++next_id;
24 // Make sure 0 is never returned because some APIs (particularly WebRequest) 22 // Make sure 0 is never returned because some APIs (particularly WebRequest)
25 // have special meaning for 0 IDs. 23 // have special meaning for 0 IDs.
26 if (next_id == 0) 24 if (next_id == 0)
27 next_id = 1; 25 next_id = 1;
28 args.GetReturnValue().Set(next_id); 26 args.GetReturnValue().Set(next_id);
29 } 27 }
30 28
31 } // namespace extensions 29 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/id_generator_custom_bindings.h ('k') | extensions/renderer/logging_native_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698