summaryrefslogtreecommitdiffstats
path: root/webkit/database/database_connections.h
blob: 02941c839d46c5147b935ebb83384686fb282609 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2009 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 WEBKIT_DATABASE_DATABASE_CONNECTIONS_H_
#define WEBKIT_DATABASE_DATABASE_CONNECTIONS_H_

#include "base/string16.h"

#include <map>

namespace webkit_database {

class DatabaseConnections {
 public:
  DatabaseConnections();
  ~DatabaseConnections();

  bool IsEmpty() const;
  bool IsDatabaseOpened(const string16& origin_identifier,
                        const string16& database_name) const;
  bool IsOriginUsed(const string16& origin_identifier) const;
  void AddConnection(const string16& origin_identifier,
                     const string16& database_name);
  void RemoveConnection(const string16& origin_identifier,
                        const string16& database_name);
  void RemoveAllConnections();
  void RemoveConnections(const DatabaseConnections& connections);

 private:
  typedef std::map<string16, int> DBConnections;
  typedef std::map<string16, DBConnections> OriginConnections;
  OriginConnections connections_;

  void RemoveConnectionsHelper(const string16& origin_identifier,
                               const string16& database_name,
                               int num_connections);
};

}  // namespace webkit_database

#endif  // WEBKIT_DATABASE_DATABASE_CONNECTIONS_H_