2 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * This library is distributed in the hope that i will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
25 #include "LocalStorageThread.h"
27 #include "LocalStorageTask.h"
28 #include "StorageAreaSync.h"
32 LocalStorageThread::LocalStorageThread()
33 : m_timer(this, &LocalStorageThread::timerFired)
37 LocalStorageThread::~LocalStorageThread()
41 bool LocalStorageThread::start()
46 void LocalStorageThread::timerFired(Timer<LocalStorageThread>*)
48 if (!m_queue.isEmpty()) {
49 RefPtr<LocalStorageTask> task = m_queue.first();
51 m_queue.removeFirst();
52 if (!m_queue.isEmpty())
53 m_timer.startOneShot(0);
57 void LocalStorageThread::scheduleImport(PassRefPtr<StorageAreaSync> area)
59 m_queue.append(LocalStorageTask::createImport(area));
60 if (!m_timer.isActive())
61 m_timer.startOneShot(0);
64 void LocalStorageThread::scheduleSync(PassRefPtr<StorageAreaSync> area)
66 m_queue.append(LocalStorageTask::createSync(area));
67 if (!m_timer.isActive())
68 m_timer.startOneShot(0);
71 void LocalStorageThread::terminate()
77 void LocalStorageThread::performTerminate()
83 } // namespace WebCore