Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: third_party/WebKit/Source/core/page/EventSource.cpp

Issue 2199743002: Measure EventSource usage in Document and Workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved. 2 * Copyright (C) 2009, 2012 Ericsson AB. All rights reserved.
3 * Copyright (C) 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (C) 2011, Code Aurora Forum. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 25 matching lines...) Expand all
36 #include "bindings/core/v8/ScriptController.h" 36 #include "bindings/core/v8/ScriptController.h"
37 #include "bindings/core/v8/SerializedScriptValue.h" 37 #include "bindings/core/v8/SerializedScriptValue.h"
38 #include "bindings/core/v8/SerializedScriptValueFactory.h" 38 #include "bindings/core/v8/SerializedScriptValueFactory.h"
39 #include "core/dom/Document.h" 39 #include "core/dom/Document.h"
40 #include "core/dom/ExceptionCode.h" 40 #include "core/dom/ExceptionCode.h"
41 #include "core/dom/ExecutionContext.h" 41 #include "core/dom/ExecutionContext.h"
42 #include "core/events/Event.h" 42 #include "core/events/Event.h"
43 #include "core/events/MessageEvent.h" 43 #include "core/events/MessageEvent.h"
44 #include "core/frame/LocalDOMWindow.h" 44 #include "core/frame/LocalDOMWindow.h"
45 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
46 #include "core/frame/UseCounter.h"
46 #include "core/frame/csp/ContentSecurityPolicy.h" 47 #include "core/frame/csp/ContentSecurityPolicy.h"
47 #include "core/inspector/ConsoleMessage.h" 48 #include "core/inspector/ConsoleMessage.h"
48 #include "core/inspector/InspectorInstrumentation.h" 49 #include "core/inspector/InspectorInstrumentation.h"
49 #include "core/loader/ThreadableLoader.h" 50 #include "core/loader/ThreadableLoader.h"
50 #include "core/page/EventSourceInit.h" 51 #include "core/page/EventSourceInit.h"
51 #include "platform/HTTPNames.h" 52 #include "platform/HTTPNames.h"
52 #include "platform/network/ResourceError.h" 53 #include "platform/network/ResourceError.h"
53 #include "platform/network/ResourceRequest.h" 54 #include "platform/network/ResourceRequest.h"
54 #include "platform/network/ResourceResponse.h" 55 #include "platform/network/ResourceResponse.h"
55 #include "platform/weborigin/SecurityOrigin.h" 56 #include "platform/weborigin/SecurityOrigin.h"
(...skipping 12 matching lines...) Expand all
68 , m_currentURL(url) 69 , m_currentURL(url)
69 , m_withCredentials(eventSourceInit.withCredentials()) 70 , m_withCredentials(eventSourceInit.withCredentials())
70 , m_state(CONNECTING) 71 , m_state(CONNECTING)
71 , m_connectTimer(this, &EventSource::connectTimerFired) 72 , m_connectTimer(this, &EventSource::connectTimerFired)
72 , m_reconnectDelay(defaultReconnectDelay) 73 , m_reconnectDelay(defaultReconnectDelay)
73 { 74 {
74 } 75 }
75 76
76 EventSource* EventSource::create(ExecutionContext* context, const String& url, c onst EventSourceInit& eventSourceInit, ExceptionState& exceptionState) 77 EventSource* EventSource::create(ExecutionContext* context, const String& url, c onst EventSourceInit& eventSourceInit, ExceptionState& exceptionState)
77 { 78 {
79 if (context->isDocument())
80 UseCounter::count(toDocument(context), UseCounter::EventSourceDocument);
81 else
82 UseCounter::count(context, UseCounter::EventSourceWorker);
83
78 if (url.isEmpty()) { 84 if (url.isEmpty()) {
79 exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSourc e to an empty URL."); 85 exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSourc e to an empty URL.");
80 return nullptr; 86 return nullptr;
81 } 87 }
82 88
83 KURL fullURL = context->completeURL(url); 89 KURL fullURL = context->completeURL(url);
84 if (!fullURL.isValid()) { 90 if (!fullURL.isValid()) {
85 exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSourc e to '" + url + "'. The URL is invalid."); 91 exceptionState.throwDOMException(SyntaxError, "Cannot open an EventSourc e to '" + url + "'. The URL is invalid.");
86 return nullptr; 92 return nullptr;
87 } 93 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 359
354 DEFINE_TRACE(EventSource) 360 DEFINE_TRACE(EventSource)
355 { 361 {
356 visitor->trace(m_parser); 362 visitor->trace(m_parser);
357 EventTargetWithInlineData::trace(visitor); 363 EventTargetWithInlineData::trace(visitor);
358 ActiveDOMObject::trace(visitor); 364 ActiveDOMObject::trace(visitor);
359 EventSourceParser::Client::trace(visitor); 365 EventSourceParser::Client::trace(visitor);
360 } 366 }
361 367
362 } // namespace blink 368 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/UseCounter.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698