1 // Copyright (c) 2010 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 "gpu/command_buffer/service/id_manager.h"
6 #include "base/logging.h"
11 IdManager::IdManager() {}
13 IdManager::~IdManager() {}
15 bool IdManager::AddMapping(GLuint client_id
, GLuint service_id
) {
16 std::pair
<MapType::iterator
, bool> result
= id_map_
.insert(
17 std::make_pair(client_id
, service_id
));
21 bool IdManager::RemoveMapping(GLuint client_id
, GLuint service_id
) {
22 MapType::iterator iter
= id_map_
.find(client_id
);
23 if (iter
!= id_map_
.end() && iter
->second
== service_id
) {
30 bool IdManager::GetServiceId(GLuint client_id
, GLuint
* service_id
) {
32 MapType::iterator iter
= id_map_
.find(client_id
);
33 if (iter
!= id_map_
.end()) {
34 *service_id
= iter
->second
;
40 bool IdManager::GetClientId(GLuint service_id
, GLuint
* client_id
) {
42 MapType::iterator
end(id_map_
.end());
43 for (MapType::iterator
iter(id_map_
.begin());
46 if (iter
->second
== service_id
) {
47 *client_id
= iter
->first
;