1 // Copyright 2014 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 "extensions/renderer/id_generator_custom_bindings.h"
11 IdGeneratorCustomBindings::IdGeneratorCustomBindings(ScriptContext
* context
)
12 : ObjectBackedNativeHandler(context
) {
13 RouteFunction("GetNextId",
14 base::Bind(&IdGeneratorCustomBindings::GetNextId
,
15 base::Unretained(this)));
18 void IdGeneratorCustomBindings::GetNextId(
19 const v8::FunctionCallbackInfo
<v8::Value
>& args
) {
20 static int32_t next_id
= 0;
22 // Make sure 0 is never returned because some APIs (particularly WebRequest)
23 // have special meaning for 0 IDs.
26 args
.GetReturnValue().Set(next_id
);
29 } // namespace extensions