예제 #1
0
Response InspectorDOMStorageAgent::getDOMStorageItems(
    std::unique_ptr<protocol::DOMStorage::StorageId> storageId,
    std::unique_ptr<protocol::Array<protocol::Array<String>>>* items) {
  LocalFrame* frame = nullptr;
  StorageArea* storageArea = nullptr;
  Response response = findStorageArea(std::move(storageId), frame, storageArea);
  if (!response.isSuccess())
    return response;

  std::unique_ptr<protocol::Array<protocol::Array<String>>> storageItems =
      protocol::Array<protocol::Array<String>>::create();

  TrackExceptionState exceptionState;
  for (unsigned i = 0; i < storageArea->length(exceptionState, frame); ++i) {
    String name(storageArea->key(i, exceptionState, frame));
    response = toResponse(exceptionState);
    if (!response.isSuccess())
      return response;
    String value(storageArea->getItem(name, exceptionState, frame));
    response = toResponse(exceptionState);
    if (!response.isSuccess())
      return response;
    std::unique_ptr<protocol::Array<String>> entry =
        protocol::Array<String>::create();
    entry->addItem(name);
    entry->addItem(value);
    storageItems->addItem(std::move(entry));
  }
  *items = std::move(storageItems);
  return Response::OK();
}
예제 #2
0
void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, const String& key)
{
    Frame* frame;
    RefPtr<StorageArea> storageArea = findStorageArea(nullptr, storageId, frame);
    if (!storageArea) {
        *errorString = "Storage not found";
        return;
    }

    storageArea->removeItem(frame, key);
}
예제 #3
0
void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, const String& key)
{
    Frame* frame;
    RefPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
    if (!storageArea) {
        *errorString = "Storage not found";
        return;
    }

    ExceptionCode exception = 0;
    storageArea->removeItem(key, exception, frame);
    *errorString = toErrorString(exception);
}
예제 #4
0
void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key)
{
    LocalFrame* frame;
    OwnPtrWillBeRawPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
    if (!storageArea) {
        *errorString = "Storage not found";
        return;
    }

    TrackExceptionState exceptionState;
    storageArea->removeItem(key, exceptionState, frame);
    *errorString = toErrorString(exceptionState);
}
void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key, const String& value)
{
    Frame* frame;
    OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame);
    if (!storageArea) {
        *errorString = "Storage not found";
        return;
    }

    TrackExceptionState es;
    storageArea->setItem(key, value, es, frame);
    *errorString = toErrorString(es);
}
예제 #6
0
Response InspectorDOMStorageAgent::removeDOMStorageItem(
    std::unique_ptr<protocol::DOMStorage::StorageId> storageId,
    const String& key) {
  LocalFrame* frame = nullptr;
  StorageArea* storageArea = nullptr;
  Response response = findStorageArea(std::move(storageId), frame, storageArea);
  if (!response.isSuccess())
    return response;

  TrackExceptionState exceptionState;
  storageArea->removeItem(key, exceptionState, frame);
  return toResponse(exceptionState);
}
예제 #7
0
void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, const String& key, const String& value)
{
    Frame* frame;
    RefPtr<StorageArea> storageArea = findStorageArea(nullptr, storageId, frame);
    if (!storageArea) {
        *errorString = "Storage not found";
        return;
    }

    bool quotaException = false;
    storageArea->setItem(frame, key, value, quotaException);
    if (quotaException)
        *errorString = ExceptionCodeDescription(QUOTA_EXCEEDED_ERR).name;
}
void InspectorDOMStorageAgent::getValue(ErrorString* errorString, const RefPtr<JSONObject>& storageId, const String& key, TypeBuilder::OptOutput<WTF::String>* value)
{
    Frame* frame;
    OwnPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, frame);
    if (!storageArea)
        return;

    TrackExceptionState es;
    bool keyPresent = storageArea->contains(key, es, frame);
    if (hadException(es, errorString) || !keyPresent)
        return;

    *value = storageArea->getItem(key, es, frame);
    hadException(es, errorString);
}
예제 #9
0
void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& items)
{
    Frame* frame;
    RefPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, frame);
    if (!storageArea)
        return;

    RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > > storageItems = TypeBuilder::Array<TypeBuilder::Array<String> >::create();

    ExceptionCode ec = 0;
    for (unsigned i = 0; i < storageArea->length(ec, frame); ++i) {
        String name(storageArea->key(i, ec, frame));
        if (hadException(ec, errorString))
            return;
        String value(storageArea->getItem(name, ec, frame));
        if (hadException(ec, errorString))
            return;
        RefPtr<TypeBuilder::Array<String> > entry = TypeBuilder::Array<String>::create();
        entry->addItem(name);
        entry->addItem(value);
        storageItems->addItem(entry);
    }
    items = storageItems.release();
}
예제 #10
0
void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, const RefPtr<InspectorObject>& storageId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Array<String>>>& items)
{
    Frame* frame;
    RefPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, frame);
    if (!storageArea) {
        if (errorString)
            *errorString = "No StorageArea for given storageId";
        return;
    }

    RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Array<String>>> storageItems = Inspector::Protocol::Array<Inspector::Protocol::Array<String>>::create();

    for (unsigned i = 0; i < storageArea->length(); ++i) {
        String key = storageArea->key(i);
        String value = storageArea->item(key);

        RefPtr<Inspector::Protocol::Array<String>> entry = Inspector::Protocol::Array<String>::create();
        entry->addItem(key);
        entry->addItem(value);
        storageItems->addItem(entry.release());
    }

    items = storageItems.release();
}