summaryrefslogtreecommitdiffstats
path: root/content/browser/indexed_db/webidbfactory_impl.cc
blob: 1fc78fac6e89cf3fb768c7bdb5520eba91781da4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2013 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.

#include "content/browser/indexed_db/webidbfactory_impl.h"

#include "base/memory/scoped_ptr.h"
#include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h"
#include "content/browser/indexed_db/indexed_db_factory.h"
#include "content/browser/indexed_db/indexed_db_factory_impl.h"
#include "third_party/WebKit/public/platform/WebIDBDatabaseCallbacks.h"
#include "third_party/WebKit/public/platform/WebIDBDatabaseError.h"

using WebKit::WebIDBCallbacks;
using WebKit::WebIDBDatabaseCallbacks;
using WebKit::WebIDBFactory;
using WebKit::WebString;

namespace content {

WebIDBFactoryImpl::WebIDBFactoryImpl()
    : idb_factory_backend_(IndexedDBFactoryImpl::Create()) {}

WebIDBFactoryImpl::~WebIDBFactoryImpl() {}

void WebIDBFactoryImpl::getDatabaseNames(WebIDBCallbacks* callbacks,
                                         const WebString& database_identifier,
                                         const WebString& data_dir) {
  idb_factory_backend_->GetDatabaseNames(
      IndexedDBCallbacksWrapper::Create(callbacks),
      database_identifier,
      data_dir);
}

void WebIDBFactoryImpl::open(const WebString& name,
                             long long version,
                             long long transaction_id,
                             WebIDBCallbacks* callbacks,
                             WebIDBDatabaseCallbacks* database_callbacks,
                             const WebString& database_identifier,
                             const WebString& data_dir) {
  scoped_refptr<IndexedDBCallbacksWrapper> callbacks_proxy =
      IndexedDBCallbacksWrapper::Create(callbacks);
  scoped_refptr<IndexedDBDatabaseCallbacksWrapper> database_callbacks_proxy =
      IndexedDBDatabaseCallbacksWrapper::Create(database_callbacks);

  callbacks_proxy->SetDatabaseCallbacks(database_callbacks_proxy);
  idb_factory_backend_->Open(name,
                             version,
                             transaction_id,
                             callbacks_proxy.get(),
                             database_callbacks_proxy.get(),
                             database_identifier,
                             data_dir);
}

void WebIDBFactoryImpl::deleteDatabase(const WebString& name,
                                       WebIDBCallbacks* callbacks,
                                       const WebString& database_identifier,
                                       const WebString& data_dir) {
  idb_factory_backend_->DeleteDatabase(
      name,
      IndexedDBCallbacksWrapper::Create(callbacks),
      database_identifier,
      data_dir);
}

}  // namespace WebKit