зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1641090, part 9 - Change IDMap into an alias for nsDataHashtable. r=nika
Now that IDMap is just a thin wrapper around an nsDataHashtable, it is easy to convert it into an alias. Differential Revision: https://phabricator.services.mozilla.com/D77169
This commit is contained in:
Родитель
81acc5f0da
Коммит
c93adfb04f
|
@ -1,49 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_ID_MAP_H__
|
||||
#define BASE_ID_MAP_H__
|
||||
|
||||
#include "base/logging.h"
|
||||
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
// This object maintains a list of IDs that can be quickly converted to
|
||||
// objects.
|
||||
//
|
||||
// Items can be inserted into the container with arbitrary ID, but the caller
|
||||
// must ensure they are unique. Inserting IDs and relying on automatically
|
||||
// generated ones is not allowed because they can collide.
|
||||
template <class T>
|
||||
class IDMap {
|
||||
private:
|
||||
using HashTable = nsDataHashtable<nsUint32HashKey, T>;
|
||||
|
||||
public:
|
||||
IDMap() {}
|
||||
IDMap(const IDMap& other) : data_(other.data_) {}
|
||||
|
||||
using const_iterator = typename HashTable::const_iterator;
|
||||
|
||||
const_iterator begin() const { return data_.begin(); }
|
||||
const_iterator end() const { return data_.end(); }
|
||||
|
||||
bool Contains(int32_t id) { return data_.Contains(id); }
|
||||
|
||||
void Put(int32_t id, const T& data) { data_.Put(id, data); }
|
||||
|
||||
void Remove(int32_t id) { data_.Remove(id); }
|
||||
|
||||
void Clear() { data_.Clear(); }
|
||||
|
||||
T Get(int32_t id) const { return data_.Get(id); }
|
||||
|
||||
protected:
|
||||
HashTable data_;
|
||||
};
|
||||
|
||||
#endif // BASE_ID_MAP_H__
|
|
@ -8,7 +8,6 @@
|
|||
#ifndef mozilla_ipc_ProtocolUtils_h
|
||||
#define mozilla_ipc_ProtocolUtils_h 1
|
||||
|
||||
#include "base/id_map.h"
|
||||
#include "base/process.h"
|
||||
#include "base/process_util.h"
|
||||
#include "chrome/common/ipc_message_utils.h"
|
||||
|
@ -33,6 +32,9 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "MainThreadUtils.h"
|
||||
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
|
||||
#if defined(ANDROID) && defined(DEBUG)
|
||||
# include <android/log.h>
|
||||
#endif
|
||||
|
@ -518,6 +520,9 @@ class IToplevelProtocol : public IProtocol {
|
|||
|
||||
int32_t NextId();
|
||||
|
||||
template <class T>
|
||||
using IDMap = nsDataHashtable<nsUint32HashKey, T>;
|
||||
|
||||
base::ProcessId mOtherPid;
|
||||
|
||||
// NOTE NOTE NOTE
|
||||
|
|
|
@ -3275,7 +3275,6 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
#include "prenv.h"
|
||||
#endif // DEBUG
|
||||
|
||||
#include "base/id_map.h"
|
||||
#include "mozilla/Tainting.h"
|
||||
#include "mozilla/ipc/MessageChannel.h"
|
||||
#include "mozilla/ipc/ProtocolUtils.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче