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.
5 #include "chrome/renderer/extensions/id_generator_custom_bindings.h"
8 #include "grit/renderer_resources.h"
9 #include "v8/include/v8.h"
11 namespace extensions
{
13 IdGeneratorCustomBindings::IdGeneratorCustomBindings(Dispatcher
* dispatcher
,
14 ChromeV8Context
* context
)
15 : ChromeV8Extension(dispatcher
, context
) {
16 RouteFunction("GetNextId", base::Bind(&IdGeneratorCustomBindings::GetNextId
,
17 base::Unretained(this)));
20 void IdGeneratorCustomBindings::GetNextId(
21 const v8::FunctionCallbackInfo
<v8::Value
>& args
) {
22 static int32_t next_id
= 0;
24 // Make sure 0 is never returned because some APIs (particularly WebRequest)
25 // have special meaning for 0 IDs.
28 args
.GetReturnValue().Set(next_id
);
31 } // namespace extensions