Changeset 138666 in webkit


Ignore:
Timestamp:
Jan 2, 2013, 3:48:58 PM (12 years ago)
Author:
alecflett@chromium.org
Message:

IndexedDB: Use non-const buffers in put() to avoid copies
https://bugs.webkit.org/show_bug.cgi?id=105572

Reviewed by Adam Barth.

Source/WebCore:

Change the new put() method to allow the implementation to consume
or adopt the vector, to avoid copying.

No new tests as this is an interface change that will be implemented later.

  • Modules/indexeddb/IDBDatabaseBackendImpl.cpp:

(WebCore::IDBDatabaseBackendImpl::put):

  • Modules/indexeddb/IDBDatabaseBackendImpl.h:

(IDBDatabaseBackendImpl):

  • Modules/indexeddb/IDBDatabaseBackendInterface.h:

Source/WebKit/chromium:

Pass on non-const Vectors to allow buffer adoption rather than copies.

  • public/WebIDBDatabase.h:

(WebIDBDatabase):
(WebKit::WebIDBDatabase::put):

  • src/IDBDatabaseBackendProxy.cpp:

(WebKit::IDBDatabaseBackendProxy::put):

  • src/IDBDatabaseBackendProxy.h:

(IDBDatabaseBackendProxy):

  • src/WebIDBDatabaseImpl.cpp:

(WebKit::WebIDBDatabaseImpl::put):

  • src/WebIDBDatabaseImpl.h:

(WebIDBDatabaseImpl):

  • tests/IDBDatabaseBackendTest.cpp:
Location:
trunk/Source
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r138665 r138666  
     12013-01-02  Alec Flett  <alecflett@chromium.org>
     2
     3        IndexedDB: Use non-const buffers in put() to avoid copies
     4        https://bugs.webkit.org/show_bug.cgi?id=105572
     5
     6        Reviewed by Adam Barth.
     7
     8        Change the new put() method to allow the implementation to consume
     9        or adopt the vector, to avoid copying.
     10
     11        No new tests as this is an interface change that will be implemented later.
     12
     13        * Modules/indexeddb/IDBDatabaseBackendImpl.cpp:
     14        (WebCore::IDBDatabaseBackendImpl::put):
     15        * Modules/indexeddb/IDBDatabaseBackendImpl.h:
     16        (IDBDatabaseBackendImpl):
     17        * Modules/indexeddb/IDBDatabaseBackendInterface.h:
     18
    1192013-01-02  Adam Barth  <abarth@webkit.org>
    220
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.cpp

    r138400 r138666  
    322322}
    323323
    324 void IDBDatabaseBackendImpl::put(int64_t transactionId, int64_t objectStoreId, const Vector<uint8_t>&, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&)
     324void IDBDatabaseBackendImpl::put(int64_t transactionId, int64_t objectStoreId, Vector<uint8_t>* value, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&)
    325325{
    326326    ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendImpl.h

    r138400 r138666  
    7979
    8080    virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE;
    81     virtual void put(int64_t transactionId, int64_t objectStoreId, const Vector<uint8_t>&, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
     81    virtual void put(int64_t transactionId, int64_t objectStoreId, Vector<uint8_t>* value, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
    8282    virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
    8383    virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, const Vector<int64_t>& indexIds) OVERRIDE;
  • trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseBackendInterface.h

    r137381 r138666  
    8181
    8282    virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) = 0;
    83     virtual void put(int64_t transactionId, int64_t objectStoreId, const Vector<uint8_t>&, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) = 0;
     83    // Note that 'value' may be consumed/adopted by this call.
     84    virtual void put(int64_t transactionId, int64_t objectStoreId, Vector<uint8_t>* value, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) = 0;
    8485    virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) = 0;
    8586    virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, const Vector<int64_t>& indexIds) = 0;
  • trunk/Source/WebKit/chromium/ChangeLog

    r138629 r138666  
     12013-01-02  Alec Flett  <alecflett@chromium.org>
     2
     3        IndexedDB: Use non-const buffers in put() to avoid copies
     4        https://bugs.webkit.org/show_bug.cgi?id=105572
     5
     6        Reviewed by Adam Barth.
     7
     8        Pass on non-const Vectors to allow buffer adoption rather than copies.
     9
     10        * public/WebIDBDatabase.h:
     11        (WebIDBDatabase):
     12        (WebKit::WebIDBDatabase::put):
     13        * src/IDBDatabaseBackendProxy.cpp:
     14        (WebKit::IDBDatabaseBackendProxy::put):
     15        * src/IDBDatabaseBackendProxy.h:
     16        (IDBDatabaseBackendProxy):
     17        * src/WebIDBDatabaseImpl.cpp:
     18        (WebKit::WebIDBDatabaseImpl::put):
     19        * src/WebIDBDatabaseImpl.h:
     20        (WebIDBDatabaseImpl):
     21        * tests/IDBDatabaseBackendTest.cpp:
     22
    1232013-01-02  Robert Kroeger  <rjkroege@chromium.org>
    224
  • trunk/Source/WebKit/chromium/public/WebIDBDatabase.h

    r137381 r138666  
    8383
    8484    virtual void get(long long transactionId, long long objectStoreId, long long indexId, const WebIDBKeyRange&, bool keyOnly, WebIDBCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
    85     virtual void put(long long transactionId, long long objectStoreId, const WebVector<unsigned char>& value, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebVector<long long>& indexIds, const WebVector<WebIndexKeys>&) { WEBKIT_ASSERT_NOT_REACHED(); }
     85    // Note that 'value' may be consumed/adopted by this call.
     86    virtual void put(long long transactionId, long long objectStoreId, WebVector<unsigned char>* value, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebVector<long long>& indexIds, const WebVector<WebIndexKeys>&) { WEBKIT_ASSERT_NOT_REACHED(); }
    8687    virtual void setIndexKeys(long long transactionId, long long objectStoreId, const WebIDBKey&, const WebVector<long long>& indexIds, const WebVector<WebIndexKeys>&) { WEBKIT_ASSERT_NOT_REACHED(); }
    8788    virtual void setIndexesReady(long long transactionId, long long objectStoreId, const WebVector<long long>& indexIds) { WEBKIT_ASSERT_NOT_REACHED(); }
  • trunk/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.cpp

    r137381 r138666  
    129129}
    130130
    131 void IDBDatabaseBackendProxy::put(int64_t transactionId, int64_t objectStoreId, const Vector<uint8_t>& buffer, PassRefPtr<IDBKey> key, PutMode putMode, PassRefPtr<IDBCallbacks> callbacks, const Vector<int64_t>& indexIds, const Vector<IndexKeys>& indexKeys)
     131void IDBDatabaseBackendProxy::put(int64_t transactionId, int64_t objectStoreId, Vector<uint8_t>* buffer, PassRefPtr<IDBKey> key, PutMode putMode, PassRefPtr<IDBCallbacks> callbacks, const Vector<int64_t>& indexIds, const Vector<IndexKeys>& indexKeys)
    132132{
    133     if (m_webIDBDatabase)
    134         m_webIDBDatabase->put(transactionId, objectStoreId, buffer, key, static_cast<WebIDBDatabase::PutMode>(putMode), new WebIDBCallbacksImpl(callbacks), indexIds, indexKeys);
     133    if (m_webIDBDatabase) {
     134        WebVector<unsigned char> webBuffer(buffer->size());
     135        webBuffer.assign(buffer->data(), buffer->size());
     136        m_webIDBDatabase->put(transactionId, objectStoreId, &webBuffer, key, static_cast<WebIDBDatabase::PutMode>(putMode), new WebIDBCallbacksImpl(callbacks), indexIds, indexKeys);
     137    }
    135138}
    136139
  • trunk/Source/WebKit/chromium/src/IDBDatabaseBackendProxy.h

    r137381 r138666  
    5656
    5757    virtual void get(int64_t transactionId, int64_t objectStoreId, int64_t indexId, PassRefPtr<WebCore::IDBKeyRange>, bool keyOnly, PassRefPtr<WebCore::IDBCallbacks>) OVERRIDE;
    58     virtual void put(int64_t transactionId, int64_t objectStoreId, const Vector<uint8_t>& value, PassRefPtr<WebCore::IDBKey>, PutMode, PassRefPtr<WebCore::IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
     58    virtual void put(int64_t transactionId, int64_t objectStoreId, Vector<uint8_t>* value, PassRefPtr<WebCore::IDBKey>, PutMode, PassRefPtr<WebCore::IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
    5959    virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<WebCore::IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE;
    6060    virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, const Vector<int64_t>& indexIds) OVERRIDE;
  • trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.cpp

    r137381 r138666  
    148148}
    149149
    150 void WebIDBDatabaseImpl::put(long long transactionId, long long objectStoreId, const WebVector<unsigned char>& value, const WebIDBKey& key, PutMode putMode, WebIDBCallbacks* callbacks, const WebVector<long long>& webIndexIds, const WebVector<WebIndexKeys>& webIndexKeys)
     150void WebIDBDatabaseImpl::put(long long transactionId, long long objectStoreId, WebVector<unsigned char>* value, const WebIDBKey& key, PutMode putMode, WebIDBCallbacks* callbacks, const WebVector<long long>& webIndexIds, const WebVector<WebIndexKeys>& webIndexKeys)
    151151{
    152152    if (!m_databaseBackend)
     
    165165    }
    166166
    167     Vector<uint8_t> valueBuffer;
    168     valueBuffer.append(value.data(), value.size());
    169     m_databaseBackend->put(transactionId, objectStoreId, valueBuffer, key, static_cast<IDBDatabaseBackendInterface::PutMode>(putMode), IDBCallbacksProxy::create(adoptPtr(callbacks)), indexIds, indexKeys);
     167    Vector<uint8_t> valueBuffer(value->size());
     168    valueBuffer.append(value->data(), value->size());
     169    m_databaseBackend->put(transactionId, objectStoreId, &valueBuffer, key, static_cast<IDBDatabaseBackendInterface::PutMode>(putMode), IDBCallbacksProxy::create(adoptPtr(callbacks)), indexIds, indexKeys);
    170170}
    171171
  • trunk/Source/WebKit/chromium/src/WebIDBDatabaseImpl.h

    r137381 r138666  
    6565
    6666    virtual void get(long long transactionId, long long objectStoreId, long long indexId, const WebIDBKeyRange&, bool keyOnly, WebIDBCallbacks*) OVERRIDE;
    67     virtual void put(long long transactionId, long long objectStoreId, const WebVector<unsigned char>& value, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebVector<long long>& indexIds, const WebVector<WebIndexKeys>&) OVERRIDE;
     67    virtual void put(long long transactionId, long long objectStoreId, WebVector<unsigned char>* value, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebVector<long long>& indexIds, const WebVector<WebIndexKeys>&) OVERRIDE;
    6868    virtual void setIndexKeys(long long transactionId, long long objectStoreId, const WebIDBKey&, const WebVector<long long>& indexIds, const WebVector<WebIndexKeys>&) OVERRIDE;
    6969    virtual void setIndexesReady(long long transactionId, long long objectStoreId, const WebVector<long long>& indexIds) OVERRIDE;
  • trunk/Source/WebKit/chromium/tests/IDBDatabaseBackendTest.cpp

    r138400 r138666  
    171171    virtual void count(int64_t objectStoreId, int64_t indexId, int64_t transactionId, PassRefPtr<IDBKeyRange>, PassRefPtr<IDBCallbacks>) OVERRIDE { }
    172172    virtual void get(int64_t objectStoreId, int64_t indexId, int64_t transactionId, PassRefPtr<IDBKeyRange>, bool keyOnly, PassRefPtr<IDBCallbacks>) OVERRIDE { }
    173     virtual void put(int64_t transactionId, int64_t objectStoreId, const Vector<uint8_t>&, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE { }
     173    virtual void put(int64_t transactionId, int64_t objectStoreId, Vector<uint8_t>*, PassRefPtr<IDBKey>, PutMode, PassRefPtr<IDBCallbacks>, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE { }
    174174    virtual void setIndexKeys(int64_t transactionId, int64_t objectStoreId, PassRefPtr<IDBKey> prpPrimaryKey, const Vector<int64_t>& indexIds, const Vector<IndexKeys>&) OVERRIDE { }
    175175    virtual void setIndexesReady(int64_t transactionId, int64_t objectStoreId, const Vector<int64_t>& indexIds) OVERRIDE { }
Note: See TracChangeset for help on using the changeset viewer.