Adjust the way GN resolves command line args into files or labels.
[chromium-blink-merge.git] / extensions / renderer / id_generator_custom_bindings.cc
blobf9c593ba7a73766f46df5a07b2292a8821efffff
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"
7 #include "base/bind.h"
9 namespace extensions {
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;
21 ++next_id;
22 // Make sure 0 is never returned because some APIs (particularly WebRequest)
23 // have special meaning for 0 IDs.
24 if (next_id == 0)
25 next_id = 1;
26 args.GetReturnValue().Set(next_id);
29 } // namespace extensions