/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

include protocol PIndexedDB;
include protocol PIndexedDBTransaction;

include "mozilla/dom/indexedDB/SerializationHelpers.h";

using mozilla::dom::indexedDB::DatabaseInfoGuts;
using mozilla::dom::indexedDB::ObjectStoreInfoGuts;
using mozilla::dom::indexedDB::IDBTransaction::Mode;

namespace mozilla {
namespace dom {
namespace indexedDB {

namespace ipc {

struct NormalTransactionParams
{
  nsString[] names;
  Mode mode;
};

struct VersionChangeTransactionParams
{
  DatabaseInfoGuts dbInfo;
  ObjectStoreInfoGuts[] osInfo;
  uint64_t oldVersion;
};

union TransactionParams
{
  NormalTransactionParams;
  VersionChangeTransactionParams;
};

} // namespace ipc

protocol PIndexedDBDatabase
{
  manager PIndexedDB;

  manages PIndexedDBTransaction;

parent:
  __delete__();

  Close(bool unlinked);

child:
  Success(DatabaseInfoGuts dbInfo, ObjectStoreInfoGuts[] osInfo);

  Error(nsresult rv);

  Blocked(uint64_t oldVersion);

  VersionChange(uint64_t oldVersion, uint64_t newVersion);

  Invalidate();

both:
  PIndexedDBTransaction(TransactionParams params);
};

} // namespace indexedDB
} // namespace dom
} // namespace mozilla
