Record all objects created by API in browser.

This commit is contained in:
Cheng Zhao 2013-04-20 21:52:46 +08:00
parent 17a9c2aea5
commit 683087fbc4
10 changed files with 163 additions and 9 deletions

View file

@ -0,0 +1,37 @@
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ATOM_BROWSER_API_ATOM_API_OBJECTS_REGISTRY_H_
#define ATOM_BROWSER_API_ATOM_API_OBJECTS_REGISTRY_H_
#include "base/id_map.h"
#include "base/basictypes.h"
namespace atom {
namespace api {
class RecordedObject;
class ObjectsRegistry {
public:
ObjectsRegistry();
virtual ~ObjectsRegistry();
int Add(RecordedObject* data) { return id_map_.Add(data); }
void Remove(int id) { id_map_.Remove(id); }
void Clear() { id_map_.Clear(); }
RecordedObject* Lookup(int id) const { return id_map_.Lookup(id); }
private:
IDMap<RecordedObject> id_map_;
DISALLOW_COPY_AND_ASSIGN(ObjectsRegistry);
};
} // namespace api
} // namespace atom
#endif // ATOM_BROWSER_API_ATOM_API_OBJECTS_REGISTRY_H_