bool BluetoothRemoteGATTCharacteristic::addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener> listener, const EventListenerOptions& options)
{
    // We will also need to unregister a characteristic once all the event
    // listeners have been removed. See http://crbug.com/541390
    if (eventType == EventTypeNames::characteristicvaluechanged) {
        WebBluetooth* webbluetooth = BluetoothSupplement::fromExecutionContext(executionContext());
        webbluetooth->registerCharacteristicObject(m_webCharacteristic->characteristicInstanceID, this);
    }
    return EventTarget::addEventListenerInternal(eventType, listener, options);
}
コード例 #2
0
ファイル: FileReader.cpp プロジェクト: eth-srl/BlinkER
void FileReader::stop()
{
    // The delayed abort task tidies up and advances to the DONE state.
    if (m_loadingState == LoadingStateAborted)
        return;

    if (hasPendingActivity())
        ThrottlingController::finishReader(executionContext(), this, ThrottlingController::removeReader(executionContext(), this));
    terminate();
}
コード例 #3
0
TEST_F(NetworkStateNotifierTest, MultipleContextsAddObserver)
{
    StateObserver observer1, observer2;
    m_notifier.addObserver(&observer1, executionContext());
    m_notifier.addObserver(&observer2, executionContext2());

    setType(ConnectionTypeBluetooth);
    EXPECT_EQ(observer1.observedType(), ConnectionTypeBluetooth);
    EXPECT_EQ(observer2.observedType(), ConnectionTypeBluetooth);
}
コード例 #4
0
TEST_F(NetworkStateNotifierTest, AddObserverWhileNotifying)
{
    StateObserver observer1, observer2;
    m_notifier.addObserver(&observer1, executionContext());
    addObserverOnNotification(&observer1, &observer2);

    setType(ConnectionTypeBluetooth);
    EXPECT_EQ(observer1.observedType(), ConnectionTypeBluetooth);
    EXPECT_EQ(observer2.observedType(), ConnectionTypeBluetooth);
}
コード例 #5
0
TEST_F(NetworkStateNotifierTest, AddObserver)
{
    StateObserver observer;
    m_notifier.addObserver(&observer, executionContext());
    EXPECT_EQ(observer.observedType(), ConnectionTypeNone);

    setType(ConnectionTypeBluetooth);
    EXPECT_EQ(observer.observedType(), ConnectionTypeBluetooth);
    EXPECT_EQ(observer.callbackCount(), 1);
}
コード例 #6
0
ファイル: UserMediaRequest.cpp プロジェクト: ewilligers/blink
void UserMediaRequest::succeed(PassRefPtr<MediaStreamDescriptor> streamDescriptor)
{
    if (!executionContext())
        return;

    RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContext(), streamDescriptor);

    MediaStreamTrackVector audioTracks = stream->getAudioTracks();
    for (MediaStreamTrackVector::iterator iter = audioTracks.begin(); iter != audioTracks.end(); ++iter) {
        (*iter)->component()->source()->setConstraints(m_audio);
    }

    MediaStreamTrackVector videoTracks = stream->getVideoTracks();
    for (MediaStreamTrackVector::iterator iter = videoTracks.begin(); iter != videoTracks.end(); ++iter) {
        (*iter)->component()->source()->setConstraints(m_video);
    }

    m_successCallback->handleEvent(stream.get());
}
コード例 #7
0
ファイル: XMLHttpRequest.cpp プロジェクト: Igalia/blink
void XMLHttpRequest::setTimeout(unsigned long timeout, ExceptionState& exceptionState)
{
    // FIXME: Need to trigger or update the timeout Timer here, if needed. http://webkit.org/b/98156
    // XHR2 spec, 4.7.3. "This implies that the timeout attribute can be set while fetching is in progress. If that occurs it will still be measured relative to the start of fetching."
    if (executionContext()->isDocument() && !m_async) {
        exceptionState.throwDOMException(InvalidAccessError, "Timeouts cannot be set for synchronous requests made from a document.");
        return;
    }
    m_timeoutMilliseconds = timeout;
}
コード例 #8
0
void EventSource::didReceiveResponse(unsigned long, const ResourceResponse& response, PassOwnPtr<WebDataConsumerHandle> handle)
{
    ASSERT_UNUSED(handle, !handle);
    ASSERT(m_state == CONNECTING);
    ASSERT(m_requestInFlight);

    m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString();
    int statusCode = response.httpStatusCode();
    bool mimeTypeIsValid = response.mimeType() == "text/event-stream";
    bool responseIsValid = statusCode == 200 && mimeTypeIsValid;
    if (responseIsValid) {
        const String& charset = response.textEncodingName();
        // If we have a charset, the only allowed value is UTF-8 (case-insensitive).
        responseIsValid = charset.isEmpty() || equalIgnoringCase(charset, "UTF-8");
        if (!responseIsValid) {
            StringBuilder message;
            message.appendLiteral("EventSource's response has a charset (\"");
            message.append(charset);
            message.appendLiteral("\") that is not UTF-8. Aborting the connection.");
            // FIXME: We are missing the source line.
            executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message.toString()));
        }
    } else {
        // To keep the signal-to-noise ratio low, we only log 200-response with an invalid MIME type.
        if (statusCode == 200 && !mimeTypeIsValid) {
            StringBuilder message;
            message.appendLiteral("EventSource's response has a MIME type (\"");
            message.append(response.mimeType());
            message.appendLiteral("\") that is not \"text/event-stream\". Aborting the connection.");
            // FIXME: We are missing the source line.
            executionContext()->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message.toString()));
        }
    }

    if (responseIsValid) {
        m_state = OPEN;
        dispatchEvent(Event::create(EventTypeNames::open));
    } else {
        m_loader->cancel();
        dispatchEvent(Event::create(EventTypeNames::error));
    }
}
コード例 #9
0
 PostMessageTimer(LocalDOMWindow& window, PassRefPtrWillBeRawPtr<MessageEvent> event, PassRefPtrWillBeRawPtr<LocalDOMWindow> source, SecurityOrigin* targetOrigin, PassRefPtrWillBeRawPtr<ScriptCallStack> stackTrace, UserGestureToken* userGestureToken)
     : SuspendableTimer(window.document())
     , m_event(event)
     , m_window(&window)
     , m_targetOrigin(targetOrigin)
     , m_stackTrace(stackTrace)
     , m_userGestureToken(userGestureToken)
     , m_preventDestruction(false)
 {
     m_asyncOperationId = InspectorInstrumentation::traceAsyncOperationStarting(executionContext(), "postMessage");
 }
コード例 #10
0
ファイル: FileReader.cpp プロジェクト: coinpayee/blink
void FileReader::executePendingRead()
{
    ASSERT(m_loadingState == LoadingStatePending);
    m_loadingState = LoadingStateLoading;

    m_loader = adoptPtr(new FileReaderLoader(m_readType, this));
    m_loader->setEncoding(m_encoding);
    m_loader->setDataType(m_blobType);
    m_loader->start(executionContext(), m_blobDataHandle);
    m_blobDataHandle = nullptr;
}
コード例 #11
0
TEST_F(NetworkStateNotifierTest, RemoveContext)
{
    StateObserver observer1, observer2;
    m_notifier.addObserver(&observer1, executionContext());
    m_notifier.addObserver(&observer2, executionContext2());
    m_notifier.removeObserver(&observer2, executionContext2());

    setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
    EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps));
    EXPECT_TRUE(verifyObservations(observer2, WebConnectionTypeNone, kNoneMaxBandwidthMbps));
}
コード例 #12
0
void Notification::close()
{
    if (m_state != NotificationStateShowing)
        return;

    if (m_persistentId == kInvalidPersistentId) {
        // Fire the close event asynchronously.
        executionContext()->postTask(BLINK_FROM_HERE, createSameThreadTask(&Notification::dispatchCloseEvent, this));

        m_state = NotificationStateClosing;
        notificationManager()->close(this);
    } else {
        m_state = NotificationStateClosed;

        SecurityOrigin* origin = executionContext()->securityOrigin();
        ASSERT(origin);

        notificationManager()->closePersistent(WebSecurityOrigin(origin), m_persistentId);
    }
}
コード例 #13
0
ファイル: AnimationPlayer.cpp プロジェクト: kjthegod/WebKit
void AnimationPlayer::setCurrentTime(double newCurrentTime)
{
    UseCounter::count(executionContext(), UseCounter::AnimationPlayerSetCurrentTime);
    if (!std::isfinite(newCurrentTime))
        return;

    PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);

    m_currentTimePending = false;
    setCurrentTimeInternal(newCurrentTime / 1000, TimingUpdateOnDemand);
}
コード例 #14
0
void MessagePort::dispatchMessages()
{
    // Messages for contexts that are not fully active get dispatched too, but JSAbstractEventListener::handleEvent() doesn't call handlers for these.
    // The HTML5 spec specifies that any messages sent to a document that is not fully active should be dropped, so this behavior is OK.
    if (!started())
        return;

    RefPtr<SerializedScriptValue> message;
    OwnPtr<MessagePortChannelArray> channels;
    while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message, channels)) {
        // close() in Worker onmessage handler should prevent next message from dispatching.
        if (executionContext()->isWorkerGlobalScope() && toWorkerGlobalScope(executionContext())->isClosing())
            return;

        OwnPtr<MessagePortArray> ports = MessagePort::entanglePorts(*executionContext(), channels.release());
        RefPtrWillBeRawPtr<Event> evt = MessageEvent::create(ports.release(), message.release());

        dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION);
    }
}
コード例 #15
0
V8PerContextData* V8CustomElementLifecycleCallbacks::creationContextData()
{
    if (!executionContext())
        return 0;

    v8::Local<v8::Context> context = m_scriptState->context();
    if (context.IsEmpty())
        return 0;

    return V8PerContextData::from(context);
}
コード例 #16
0
ファイル: IDBRequest.cpp プロジェクト: Metrological/chromium
bool IDBRequest::shouldEnqueueEvent() const
{
    if (m_contextStopped || !executionContext())
        return false;
    ASSERT(m_readyState == PENDING || m_readyState == DONE);
    if (m_requestAborted)
        return false;
    ASSERT(m_readyState == PENDING);
    ASSERT(!m_error && !m_result);
    return true;
}
コード例 #17
0
ファイル: XMLHttpRequest.cpp プロジェクト: Igalia/blink
void XMLHttpRequest::send(ArrayBuffer* body, ExceptionState& exceptionState)
{
    WTF_LOG(Network, "XMLHttpRequest %p send() ArrayBuffer %p", this, body);

    String consoleMessage("ArrayBuffer is deprecated in XMLHttpRequest.send(). Use ArrayBufferView instead.");
    executionContext()->addConsoleMessage(JSMessageSource, WarningMessageLevel, consoleMessage);

    blink::Platform::current()->histogramEnumeration("WebCore.XHR.send.ArrayBufferOrView", XMLHttpRequestSendArrayBuffer, XMLHttpRequestSendArrayBufferOrViewMax);

    sendBytesData(body->data(), body->byteLength(), exceptionState);
}
コード例 #18
0
void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate)
{
    ASSERT(!m_closed);
    ASSERT(executionContext()->isContextThread());
    if (webCandidate.isNull())
        scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr));
    else {
        RTCIceCandidate* iceCandidate = RTCIceCandidate::create(webCandidate);
        scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCandidate));
    }
}
コード例 #19
0
void V8CustomElementLifecycleCallbacks::created(Element* element)
{
    // FIXME: callbacks while paused should be queued up for execution to
    // continue then be delivered in order rather than delivered immediately.
    // Bug 329665 tracks similar behavior for other synchronous events.
    if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
        return;

    element->setCustomElementState(Element::Upgraded);

    if (m_scriptState->contextIsEmpty())
        return;
    ScriptState::Scope scope(m_scriptState.get());
    v8::Isolate* isolate = m_scriptState->isolate();
    v8::Handle<v8::Context> context = m_scriptState->context();
    v8::Handle<v8::Object> receiver = m_scriptState->world().domDataStore().get<V8Element>(element, isolate);
    if (!receiver.IsEmpty()) {
        // Swizzle the prototype of the existing wrapper. We don't need to
        // worry about non-existent wrappers; they will get the right
        // prototype when wrapped.
        v8::Handle<v8::Object> prototype = m_prototype.newLocal(isolate);
        if (prototype.IsEmpty())
            return;
        receiver->SetPrototype(prototype);
    }

    v8::Handle<v8::Function> callback = m_created.newLocal(isolate);
    if (callback.IsEmpty())
        return;

    if (receiver.IsEmpty())
        receiver = toV8(element, context->Global(), isolate).As<v8::Object>();

    ASSERT(!receiver.IsEmpty());

    InspectorInstrumentation::willExecuteCustomElementCallback(element);

    v8::TryCatch exceptionCatcher;
    exceptionCatcher.SetVerbose(true);
    ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate);
}
コード例 #20
0
void NetworkInformation::connectionTypeChange(blink::WebConnectionType type)
{
    ASSERT(executionContext()->isContextThread());

    // This can happen if the observer removes and then adds itself again
    // during notification.
    if (m_type == type)
        return;

    m_type = type;
    dispatchEvent(Event::create(EventTypeNames::typechange));
}
コード例 #21
0
void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion)
{
    IDB_TRACE("IDBDatabase::onVersionChange");
    if (m_contextStopped || !executionContext())
        return;

    if (m_closePending)
        return;

    Nullable<unsigned long long> newVersionNullable = (newVersion == IDBDatabaseMetadata::NoIntVersion) ? Nullable<unsigned long long>() : Nullable<unsigned long long>(newVersion);
    enqueueEvent(IDBVersionChangeEvent::create(EventTypeNames::versionchange, oldVersion, newVersionNullable));
}
コード例 #22
0
ファイル: IDBRequest.cpp プロジェクト: 335969568/Blink-1
void IDBRequest::abort()
{
    ASSERT(!m_requestAborted);
    if (m_contextStopped || !executionContext())
        return;
    ASSERT(m_readyState == PENDING || m_readyState == DONE);
    if (m_readyState == DONE)
        return;

    EventQueue* eventQueue = executionContext()->eventQueue();
    for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
        bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get());
        ASSERT_UNUSED(removed, removed);
    }
    m_enqueuedEvents.clear();

    m_error.clear();
    m_result.clear();
    onError(DOMError::create(AbortError, "The transaction was aborted, so the request cannot be fulfilled."));
    m_requestAborted = true;
}
コード例 #23
0
void MIDIAccess::stop()
{
    m_hasAccess = false;
    if (!m_requesting)
        return;
    m_requesting = false;
    Document* document = toDocument(executionContext());
    ASSERT(document);
    MIDIController* controller = MIDIController::from(document->page());
    ASSERT(controller);
    controller->cancelSysExPermissionRequest(this);
}
コード例 #24
0
TEST_F(NetworkStateNotifierTest, RemoveSoleObserverWhileNotifying)
{
    StateObserver observer1;
    m_notifier.addObserver(&observer1, executionContext());
    removeObserverOnNotification(&observer1, &observer1);

    setConnection(WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps);
    EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps));

    setConnection(WebConnectionTypeEthernet, kEthernetMaxBandwidthMbps);
    EXPECT_TRUE(verifyObservations(observer1, WebConnectionTypeBluetooth, kBluetoothMaxBandwidthMbps));
}
コード例 #25
0
ファイル: AnimationPlayer.cpp プロジェクト: kjthegod/WebKit
void AnimationPlayer::setPlaybackRate(double playbackRate)
{
    UseCounter::count(executionContext(), UseCounter::AnimationPlayerSetPlaybackRate);
    if (!std::isfinite(playbackRate))
        return;
    if (playbackRate == m_playbackRate)
        return;

    PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);

    setPlaybackRateInternal(playbackRate);
}
コード例 #26
0
ファイル: IDBDatabase.cpp プロジェクト: Igalia/blink
void IDBDatabase::closeConnection()
{
    ASSERT(m_closePending);
    ASSERT(m_transactions.isEmpty());

    m_backend->close();
    m_backend.clear();

    if (m_contextStopped || !executionContext())
        return;

    EventQueue* eventQueue = executionContext()->eventQueue();
    // Remove any pending versionchange events scheduled to fire on this
    // connection. They would have been scheduled by the backend when another
    // connection called setVersion, but the frontend connection is being
    // closed before they could fire.
    for (size_t i = 0; i < m_enqueuedEvents.size(); ++i) {
        bool removed = eventQueue->cancelEvent(m_enqueuedEvents[i].get());
        ASSERT_UNUSED(removed, removed);
    }
}
コード例 #27
0
void EventSource::networkRequestEnded()
{
    if (!m_requestInFlight)
        return;

    InspectorInstrumentation::didFinishEventSourceRequest(executionContext(), this);

    m_requestInFlight = false;

    if (m_state != CLOSED)
        scheduleReconnect();
}
コード例 #28
0
void IDBDatabase::onVersionChange(int64_t oldVersion, int64_t newVersion)
{
    IDB_TRACE("IDBDatabase::onVersionChange");
    if (m_contextStopped || !executionContext())
        return;

    if (m_closePending)
        return;

    RefPtr<IDBAny> newVersionAny = newVersion == IDBDatabaseMetadata::NoIntVersion ? IDBAny::createNull() : IDBAny::create(newVersion);
    enqueueEvent(IDBVersionChangeEvent::create(IDBAny::create(oldVersion), newVersionAny.release(), EventTypeNames::versionchange));
}
コード例 #29
0
ファイル: IDBRequest.cpp プロジェクト: kjthegod/WebKit
ScriptValue IDBRequest::result(ExceptionState& exceptionState)
{
    if (m_readyState != DONE) {
        exceptionState.throwDOMException(InvalidStateError, IDBDatabase::requestNotFinishedErrorMessage);
        return ScriptValue();
    }
    if (m_contextStopped || !executionContext())
        return ScriptValue();
    m_resultDirty = false;
    ScriptValue value = idbAnyToScriptValue(m_scriptState.get(), m_result);
    return value;
}
コード例 #30
0
void IntersectionObserverController::deliverIntersectionObservations(Timer<IntersectionObserverController>*)
{
    if (executionContext()->activeDOMObjectsAreSuspended()) {
        m_timerFiredWhileSuspended = true;
        return;
    }
    IntersectionObserverVector observers;
    copyToVector(m_pendingIntersectionObservers, observers);
    m_pendingIntersectionObservers.clear();
    for (auto& observer : observers)
        observer->deliver();
}