Web Replay: purge remaining PassRefPtr uses and minor cleanup
authorburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jan 2015 22:13:08 +0000 (22:13 +0000)
committerburg@cs.washington.edu <burg@cs.washington.edu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 16 Jan 2015 22:13:08 +0000 (22:13 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140456

Reviewed by Andreas Kling.

Source/JavaScriptCore:

Get rid of PassRefPtr. Introduce default initializers where it makes sense.
Remove mistaken uses of AtomicString that were not removed as part of r174113.

* replay/EmptyInputCursor.h:
* replay/InputCursor.h:
(JSC::InputCursor::InputCursor):

Source/WebCore:

Get rid of PassRefPtr. Introduce default initializers where it makes sense. Change
uses of ASSERT to ASSERT_ARG when the assert is a precondition on an argument.

Remove mistaken uses of AtomicString that were not removed as part of r174113.

No new tests, no behavior changed.

* inspector/InspectorReplayAgent.cpp:
(WebCore::SerializeInputToJSONFunctor::operator()):
(WebCore::SerializeInputToJSONFunctor::returnValue):
(WebCore::InspectorReplayAgent::sessionCreated):
(WebCore::InspectorReplayAgent::sessionModified):
(WebCore::InspectorReplayAgent::sessionLoaded):
(WebCore::InspectorReplayAgent::segmentCreated):
(WebCore::InspectorReplayAgent::segmentCompleted):
(WebCore::InspectorReplayAgent::segmentLoaded):
(WebCore::InspectorReplayAgent::switchSession):
(WebCore::InspectorReplayAgent::insertSessionSegment):
(WebCore::InspectorReplayAgent::removeSessionSegment):
(WebCore::InspectorReplayAgent::findSession):
(WebCore::InspectorReplayAgent::findSegment):
* inspector/InspectorReplayAgent.h:
* replay/CapturingInputCursor.cpp:
(WebCore::CapturingInputCursor::CapturingInputCursor):
(WebCore::CapturingInputCursor::create):
(WebCore::CapturingInputCursor::loadInput):
* replay/CapturingInputCursor.h:
* replay/EventLoopInputDispatcher.cpp:
(WebCore::EventLoopInputDispatcher::EventLoopInputDispatcher):
* replay/EventLoopInputDispatcher.h:
* replay/FunctorInputCursor.h:
(WebCore::FunctorInputCursor::FunctorInputCursor):
(WebCore::FunctorInputCursor::loadInput):
* replay/ReplayController.cpp:
(WebCore::ReplayController::ReplayController):
(WebCore::ReplayController::setForceDeterministicSettings):
(WebCore::ReplayController::setSessionState):
(WebCore::ReplayController::setSegmentState):
(WebCore::ReplayController::switchSession):
(WebCore::ReplayController::createSegment):
(WebCore::ReplayController::completeSegment):
(WebCore::ReplayController::loadSegmentAtIndex):
(WebCore::ReplayController::unloadSegment):
(WebCore::ReplayController::frameNavigated):
(WebCore::ReplayController::loadedSession):
(WebCore::ReplayController::loadedSegment):
(WebCore::ReplayController::activeInputCursor):
(WebCore::ReplayController::dispatcher):
* replay/ReplayController.h:
* replay/ReplaySession.cpp:
(WebCore::ReplaySession::create):
(WebCore::ReplaySession::at):
(WebCore::ReplaySession::appendSegment):
(WebCore::ReplaySession::insertSegment):
(WebCore::ReplaySession::removeSegment):
* replay/ReplaySession.h:
* replay/ReplaySessionSegment.cpp:
(WebCore::ReplaySessionSegment::create):
(WebCore::ReplaySessionSegment::ReplaySessionSegment):
* replay/ReplaySessionSegment.h:
* replay/ReplayingInputCursor.cpp:
(WebCore::ReplayingInputCursor::ReplayingInputCursor):
(WebCore::ReplayingInputCursor::create):
(WebCore::ReplayingInputCursor::loadInput):
* replay/ReplayingInputCursor.h:
* replay/SegmentedInputStorage.cpp:
(WebCore::SegmentedInputStorage::store):
(WebCore::SegmentedInputStorage::queue):
(WebCore::SegmentedInputStorage::SegmentedInputStorage): Deleted.
* replay/SegmentedInputStorage.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178603 268f45cc-cd09-0410-ab3c-d52691b4dbfc

21 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/replay/EmptyInputCursor.h
Source/JavaScriptCore/replay/InputCursor.h
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorReplayAgent.cpp
Source/WebCore/inspector/InspectorReplayAgent.h
Source/WebCore/replay/CapturingInputCursor.cpp
Source/WebCore/replay/CapturingInputCursor.h
Source/WebCore/replay/EventLoopInputDispatcher.cpp
Source/WebCore/replay/EventLoopInputDispatcher.h
Source/WebCore/replay/FunctorInputCursor.h
Source/WebCore/replay/ReplayController.cpp
Source/WebCore/replay/ReplayController.h
Source/WebCore/replay/ReplaySession.cpp
Source/WebCore/replay/ReplaySession.h
Source/WebCore/replay/ReplaySessionSegment.cpp
Source/WebCore/replay/ReplaySessionSegment.h
Source/WebCore/replay/ReplayingInputCursor.cpp
Source/WebCore/replay/ReplayingInputCursor.h
Source/WebCore/replay/SegmentedInputStorage.cpp
Source/WebCore/replay/SegmentedInputStorage.h

index 288d229..cee00d9 100644 (file)
@@ -1,5 +1,19 @@
 2015-01-16  Brian J. Burg  <burg@cs.washington.edu>
 
+        Web Replay: purge remaining PassRefPtr uses and minor cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=140456
+
+        Reviewed by Andreas Kling.
+
+        Get rid of PassRefPtr. Introduce default initializers where it makes sense.
+        Remove mistaken uses of AtomicString that were not removed as part of r174113.
+
+        * replay/EmptyInputCursor.h:
+        * replay/InputCursor.h:
+        (JSC::InputCursor::InputCursor):
+
+2015-01-16  Brian J. Burg  <burg@cs.washington.edu>
+
         Web Inspector: code generator should fail on duplicate parameter and member names
         https://bugs.webkit.org/show_bug.cgi?id=140555
 
index f2a9a40..a38aee2 100644 (file)
@@ -40,9 +40,9 @@ class EmptyInputCursor final : public InputCursor {
 public:
     virtual ~EmptyInputCursor() { }
 
-    static PassRefPtr<EmptyInputCursor> create()
+    static Ref<EmptyInputCursor> create()
     {
-        return adoptRef(new EmptyInputCursor());
+        return adoptRef(*new EmptyInputCursor());
     }
 
     virtual bool isCapturing() const override { return false; }
@@ -60,7 +60,7 @@ public:
     }
 
 protected:
-    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString&) override
+    virtual NondeterministicInputBase* loadInput(InputQueue, const String&) override
     {
         ASSERT_NOT_REACHED();
         return nullptr;
index 5c2a85e..6cdb292 100644 (file)
 #include "NondeterministicInput.h"
 #include <wtf/Noncopyable.h>
 #include <wtf/RefCounted.h>
-#include <wtf/text/AtomicString.h>
 
 namespace JSC {
 
 class InputCursor : public RefCounted<InputCursor> {
     WTF_MAKE_NONCOPYABLE(InputCursor);
 public:
-    InputCursor()
-        : m_withinEventLoopInputExtent(false)
-    {
-    }
-
+    InputCursor() { }
     virtual ~InputCursor() { }
 
     virtual bool isCapturing() const = 0;
@@ -78,10 +73,10 @@ public:
     virtual void storeInput(std::unique_ptr<NondeterministicInputBase>) = 0;
     virtual NondeterministicInputBase* uncheckedLoadInput(InputQueue) = 0;
 protected:
-    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString&) = 0;
+    virtual NondeterministicInputBase* loadInput(InputQueue, const String&) = 0;
 
 private:
-    bool m_withinEventLoopInputExtent;
+    bool m_withinEventLoopInputExtent {false};
 };
 
 } // namespace JSC
index ada35de..b51b89f 100644 (file)
@@ -1,3 +1,81 @@
+2015-01-16  Brian J. Burg  <burg@cs.washington.edu>
+
+        Web Replay: purge remaining PassRefPtr uses and minor cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=140456
+
+        Reviewed by Andreas Kling.
+
+        Get rid of PassRefPtr. Introduce default initializers where it makes sense. Change
+        uses of ASSERT to ASSERT_ARG when the assert is a precondition on an argument.
+
+        Remove mistaken uses of AtomicString that were not removed as part of r174113.
+
+        No new tests, no behavior changed.
+
+        * inspector/InspectorReplayAgent.cpp:
+        (WebCore::SerializeInputToJSONFunctor::operator()):
+        (WebCore::SerializeInputToJSONFunctor::returnValue):
+        (WebCore::InspectorReplayAgent::sessionCreated):
+        (WebCore::InspectorReplayAgent::sessionModified):
+        (WebCore::InspectorReplayAgent::sessionLoaded):
+        (WebCore::InspectorReplayAgent::segmentCreated):
+        (WebCore::InspectorReplayAgent::segmentCompleted):
+        (WebCore::InspectorReplayAgent::segmentLoaded):
+        (WebCore::InspectorReplayAgent::switchSession):
+        (WebCore::InspectorReplayAgent::insertSessionSegment):
+        (WebCore::InspectorReplayAgent::removeSessionSegment):
+        (WebCore::InspectorReplayAgent::findSession):
+        (WebCore::InspectorReplayAgent::findSegment):
+        * inspector/InspectorReplayAgent.h:
+        * replay/CapturingInputCursor.cpp:
+        (WebCore::CapturingInputCursor::CapturingInputCursor):
+        (WebCore::CapturingInputCursor::create):
+        (WebCore::CapturingInputCursor::loadInput):
+        * replay/CapturingInputCursor.h:
+        * replay/EventLoopInputDispatcher.cpp:
+        (WebCore::EventLoopInputDispatcher::EventLoopInputDispatcher):
+        * replay/EventLoopInputDispatcher.h:
+        * replay/FunctorInputCursor.h:
+        (WebCore::FunctorInputCursor::FunctorInputCursor):
+        (WebCore::FunctorInputCursor::loadInput):
+        * replay/ReplayController.cpp:
+        (WebCore::ReplayController::ReplayController):
+        (WebCore::ReplayController::setForceDeterministicSettings):
+        (WebCore::ReplayController::setSessionState):
+        (WebCore::ReplayController::setSegmentState):
+        (WebCore::ReplayController::switchSession):
+        (WebCore::ReplayController::createSegment):
+        (WebCore::ReplayController::completeSegment):
+        (WebCore::ReplayController::loadSegmentAtIndex):
+        (WebCore::ReplayController::unloadSegment):
+        (WebCore::ReplayController::frameNavigated):
+        (WebCore::ReplayController::loadedSession):
+        (WebCore::ReplayController::loadedSegment):
+        (WebCore::ReplayController::activeInputCursor):
+        (WebCore::ReplayController::dispatcher):
+        * replay/ReplayController.h:
+        * replay/ReplaySession.cpp:
+        (WebCore::ReplaySession::create):
+        (WebCore::ReplaySession::at):
+        (WebCore::ReplaySession::appendSegment):
+        (WebCore::ReplaySession::insertSegment):
+        (WebCore::ReplaySession::removeSegment):
+        * replay/ReplaySession.h:
+        * replay/ReplaySessionSegment.cpp:
+        (WebCore::ReplaySessionSegment::create):
+        (WebCore::ReplaySessionSegment::ReplaySessionSegment):
+        * replay/ReplaySessionSegment.h:
+        * replay/ReplayingInputCursor.cpp:
+        (WebCore::ReplayingInputCursor::ReplayingInputCursor):
+        (WebCore::ReplayingInputCursor::create):
+        (WebCore::ReplayingInputCursor::loadInput):
+        * replay/ReplayingInputCursor.h:
+        * replay/SegmentedInputStorage.cpp:
+        (WebCore::SegmentedInputStorage::store):
+        (WebCore::SegmentedInputStorage::queue):
+        (WebCore::SegmentedInputStorage::SegmentedInputStorage): Deleted.
+        * replay/SegmentedInputStorage.h:
+
 2015-01-16  Andreas Kling  <akling@apple.com>
 
         Remove assertion that Page::m_editorClient is non-null.
index 8fc441e..06105d5 100644 (file)
@@ -118,10 +118,10 @@ public:
         LOG(WebReplay, "%-25s Writing %5zu: %s\n", "[SerializeInput]", index, input->type().ascii().data());
 
         if (RefPtr<Inspector::Protocol::Replay::ReplayInput> serializedInput = buildInspectorObjectForInput(*input, index))
-            m_inputs->addItem(serializedInput.release());
+            m_inputs->addItem(WTF::move(serializedInput));
     }
 
-    ReturnType returnValue() { return m_inputs.release(); }
+    ReturnType returnValue() { return WTF::move(m_inputs); }
 private:
     RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Replay::ReplayInput>> m_inputs;
 };
@@ -214,10 +214,8 @@ void InspectorReplayAgent::willDispatchEvent(const Event& event, Frame* frame)
         m_page.replayController().willDispatchEvent(event, frame);
 }
 
-void InspectorReplayAgent::sessionCreated(PassRefPtr<ReplaySession> prpSession)
+void InspectorReplayAgent::sessionCreated(RefPtr<ReplaySession>&& session)
 {
-    RefPtr<ReplaySession> session = prpSession;
-
     auto result = m_sessionsMap.add(session->identifier(), session);
     // Can't have two sessions with same identifier.
     ASSERT_UNUSED(result, result.isNewEntry);
@@ -225,25 +223,21 @@ void InspectorReplayAgent::sessionCreated(PassRefPtr<ReplaySession> prpSession)
     m_frontendDispatcher->sessionCreated(session->identifier());
 }
 
-void InspectorReplayAgent::sessionModified(PassRefPtr<ReplaySession> session)
+void InspectorReplayAgent::sessionModified(RefPtr<ReplaySession>&& session)
 {
     m_frontendDispatcher->sessionModified(session->identifier());
 }
 
-void InspectorReplayAgent::sessionLoaded(PassRefPtr<ReplaySession> prpSession)
+void InspectorReplayAgent::sessionLoaded(RefPtr<ReplaySession>&& session)
 {
-    RefPtr<ReplaySession> session = prpSession;
-
     // In case we didn't know about the loaded session, add here.
     m_sessionsMap.add(session->identifier(), session);
 
     m_frontendDispatcher->sessionLoaded(session->identifier());
 }
 
-void InspectorReplayAgent::segmentCreated(PassRefPtr<ReplaySessionSegment> prpSegment)
+void InspectorReplayAgent::segmentCreated(RefPtr<ReplaySessionSegment>&& segment)
 {
-    RefPtr<ReplaySessionSegment> segment = prpSegment;
-
     auto result = m_segmentsMap.add(segment->identifier(), segment);
     // Can't have two segments with the same identifier.
     ASSERT_UNUSED(result, result.isNewEntry);
@@ -251,17 +245,15 @@ void InspectorReplayAgent::segmentCreated(PassRefPtr<ReplaySessionSegment> prpSe
     m_frontendDispatcher->segmentCreated(segment->identifier());
 }
 
-void InspectorReplayAgent::segmentCompleted(PassRefPtr<ReplaySessionSegment> segment)
+void InspectorReplayAgent::segmentCompleted(RefPtr<ReplaySessionSegment>&& segment)
 {
     m_frontendDispatcher->segmentCompleted(segment->identifier());
 }
 
-void InspectorReplayAgent::segmentLoaded(PassRefPtr<ReplaySessionSegment> prpSegment)
+void InspectorReplayAgent::segmentLoaded(RefPtr<ReplaySessionSegment>&& segment)
 {
-    RefPtr<ReplaySessionSegment> segment = prpSegment;
-
     // In case we didn't know about the loaded segment, add here.
-    m_segmentsMap.add(segment->identifier(), segment);
+    m_segmentsMap.add(segment->identifier(), segment.copyRef());
 
     m_frontendDispatcher->segmentLoaded(segment->identifier());
 }
@@ -384,7 +376,7 @@ void InspectorReplayAgent::cancelPlayback(ErrorString& errorString)
 
 void InspectorReplayAgent::switchSession(ErrorString& errorString, Inspector::Protocol::Replay::SessionIdentifier identifier)
 {
-    ASSERT(identifier > 0);
+    ASSERT_ARG(identifier, identifier > 0);
 
     if (sessionState() != WebCore::SessionState::Inactive) {
         errorString = ASCIILiteral("Can't switch sessions unless the session is neither capturing or replaying.");
@@ -395,14 +387,14 @@ void InspectorReplayAgent::switchSession(ErrorString& errorString, Inspector::Pr
     if (!session)
         return;
 
-    m_page.replayController().switchSession(session);
+    m_page.replayController().switchSession(WTF::move(session));
 }
 
 void InspectorReplayAgent::insertSessionSegment(ErrorString& errorString, Inspector::Protocol::Replay::SessionIdentifier sessionIdentifier, SegmentIdentifier segmentIdentifier, int segmentIndex)
 {
-    ASSERT(sessionIdentifier > 0);
-    ASSERT(segmentIdentifier > 0);
-    ASSERT(segmentIndex >= 0);
+    ASSERT_ARG(sessionIdentifier, sessionIdentifier > 0);
+    ASSERT_ARG(segmentIdentifier, segmentIdentifier > 0);
+    ASSERT_ARG(segmentIndex, segmentIndex >= 0);
 
     RefPtr<ReplaySession> session = findSession(errorString, sessionIdentifier);
     RefPtr<ReplaySessionSegment> segment = findSegment(errorString, segmentIdentifier);
@@ -420,14 +412,14 @@ void InspectorReplayAgent::insertSessionSegment(ErrorString& errorString, Inspec
         return;
     }
 
-    session->insertSegment(segmentIndex, segment);
-    sessionModified(session);
+    session->insertSegment(segmentIndex, WTF::move(segment));
+    sessionModified(WTF::move(session));
 }
 
 void InspectorReplayAgent::removeSessionSegment(ErrorString& errorString, Inspector::Protocol::Replay::SessionIdentifier identifier, int segmentIndex)
 {
-    ASSERT(identifier > 0);
-    ASSERT(segmentIndex >= 0);
+    ASSERT_ARG(identifier, identifier > 0);
+    ASSERT_ARG(segmentIndex, segmentIndex >= 0);
 
     RefPtr<ReplaySession> session = findSession(errorString, identifier);
 
@@ -445,12 +437,12 @@ void InspectorReplayAgent::removeSessionSegment(ErrorString& errorString, Inspec
     }
 
     session->removeSegment(segmentIndex);
-    sessionModified(session);
+    sessionModified(WTF::move(session));
 }
 
-PassRefPtr<ReplaySession> InspectorReplayAgent::findSession(ErrorString& errorString, SessionIdentifier identifier)
+RefPtr<ReplaySession> InspectorReplayAgent::findSession(ErrorString& errorString, SessionIdentifier identifier)
 {
-    ASSERT(identifier > 0);
+    ASSERT_ARG(identifier, identifier > 0);
 
     auto it = m_sessionsMap.find(identifier);
     if (it == m_sessionsMap.end()) {
@@ -461,9 +453,9 @@ PassRefPtr<ReplaySession> InspectorReplayAgent::findSession(ErrorString& errorSt
     return it->value;
 }
 
-PassRefPtr<ReplaySessionSegment> InspectorReplayAgent::findSegment(ErrorString& errorString, SegmentIdentifier identifier)
+RefPtr<ReplaySessionSegment> InspectorReplayAgent::findSegment(ErrorString& errorString, SegmentIdentifier identifier)
 {
-    ASSERT(identifier > 0);
+    ASSERT_ARG(identifier, identifier > 0);
 
     auto it = m_segmentsMap.find(identifier);
     if (it == m_segmentsMap.end()) {
index 9429511..11f2a94 100644 (file)
@@ -73,14 +73,14 @@ public:
     void willDispatchEvent(const Event&, Frame*);
 
     // Notifications from ReplayController.
-    void sessionCreated(PassRefPtr<ReplaySession>);
+    void sessionCreated(RefPtr<ReplaySession>&&);
     // This is called internally (when adding/removing) and by ReplayController during capture.
-    void sessionModified(PassRefPtr<ReplaySession>);
-    void sessionLoaded(PassRefPtr<ReplaySession>);
+    void sessionModified(RefPtr<ReplaySession>&&);
+    void sessionLoaded(RefPtr<ReplaySession>&&);
 
-    void segmentCreated(PassRefPtr<ReplaySessionSegment>);
-    void segmentCompleted(PassRefPtr<ReplaySessionSegment>);
-    void segmentLoaded(PassRefPtr<ReplaySessionSegment>);
+    void segmentCreated(RefPtr<ReplaySessionSegment>&&);
+    void segmentCompleted(RefPtr<ReplaySessionSegment>&&);
+    void segmentLoaded(RefPtr<ReplaySessionSegment>&&);
     void segmentUnloaded();
 
     void captureStarted();
@@ -110,8 +110,8 @@ public:
     virtual void getSegmentData(ErrorString&, Inspector::Protocol::Replay::SegmentIdentifier, RefPtr<Inspector::Protocol::Replay::SessionSegment>&) override;
 
 private:
-    PassRefPtr<ReplaySession> findSession(ErrorString&, SessionIdentifier);
-    PassRefPtr<ReplaySessionSegment> findSegment(ErrorString&, SegmentIdentifier);
+    RefPtr<ReplaySession> findSession(ErrorString&, SessionIdentifier);
+    RefPtr<ReplaySessionSegment> findSegment(ErrorString&, SegmentIdentifier);
     WebCore::SessionState sessionState() const;
 
     std::unique_ptr<Inspector::InspectorReplayFrontendDispatcher> m_frontendDispatcher;
index 885df58..03cee92 100644 (file)
@@ -38,8 +38,8 @@
 
 namespace WebCore {
 
-CapturingInputCursor::CapturingInputCursor(PassRefPtr<ReplaySessionSegment> segment)
-    : m_segment(segment)
+CapturingInputCursor::CapturingInputCursor(RefPtr<ReplaySessionSegment>&& segment)
+    : m_segment(WTF::move(segment))
 {
     LOG(WebReplay, "%-30sCreated capture cursor=%p.\n", "[ReplayController]", this);
 }
@@ -49,9 +49,9 @@ CapturingInputCursor::~CapturingInputCursor()
     LOG(WebReplay, "%-30sDestroyed capture cursor=%p.\n", "[ReplayController]", this);
 }
 
-Ref<CapturingInputCursor> CapturingInputCursor::create(PassRefPtr<ReplaySessionSegment> segment)
+Ref<CapturingInputCursor> CapturingInputCursor::create(RefPtr<ReplaySessionSegment>&& segment)
 {
-    return adoptRef(*new CapturingInputCursor(segment));
+    return adoptRef(*new CapturingInputCursor(WTF::move(segment)));
 }
 
 void CapturingInputCursor::storeInput(std::unique_ptr<NondeterministicInputBase> input)
@@ -67,7 +67,7 @@ void CapturingInputCursor::storeInput(std::unique_ptr<NondeterministicInputBase>
     m_segment->storage().store(WTF::move(input));
 }
 
-NondeterministicInputBase* CapturingInputCursor::loadInput(InputQueue, const AtomicString&)
+NondeterministicInputBase* CapturingInputCursor::loadInput(InputQueue, const String&)
 {
     // Can't load inputs from capturing cursor.
     ASSERT_NOT_REACHED();
index 08017ab..a414c2e 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <replay/InputCursor.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
 
 namespace WebCore {
 
@@ -42,17 +43,17 @@ class ReplaySessionSegment;
 class CapturingInputCursor final : public InputCursor {
     WTF_MAKE_NONCOPYABLE(CapturingInputCursor);
 public:
-    static Ref<CapturingInputCursor> create(PassRefPtr<ReplaySessionSegment>);
+    static Ref<CapturingInputCursor> create(RefPtr<ReplaySessionSegment>&&);
     virtual ~CapturingInputCursor();
 
     virtual bool isCapturing() const override { return true; }
     virtual bool isReplaying() const override { return false; }
 
 protected:
-    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString& type) override;
+    virtual NondeterministicInputBase* loadInput(InputQueue, const String& type) override;
 
 private:
-    CapturingInputCursor(PassRefPtr<ReplaySessionSegment>);
+    CapturingInputCursor(RefPtr<ReplaySessionSegment>&&);
 
     virtual NondeterministicInputBase* uncheckedLoadInput(InputQueue) override;
     virtual void storeInput(std::unique_ptr<NondeterministicInputBase>) override;
index 8f43618..cd8b93c 100644 (file)
@@ -49,11 +49,7 @@ EventLoopInputDispatcher::EventLoopInputDispatcher(Page& page, ReplayingInputCur
     , m_client(client)
     , m_cursor(cursor)
     , m_timer(*this, &EventLoopInputDispatcher::timerFired)
-    , m_dispatching(false)
-    , m_running(false)
     , m_speed(DispatchSpeed::FastForward)
-    , m_previousDispatchStartTime(0.0)
-    , m_previousInputTimestamp(0.0)
 {
     m_currentWork.input = nullptr;
     m_currentWork.timestamp = 0.0;
index 5934c40..41656d2 100644 (file)
@@ -82,15 +82,15 @@ private:
     // This data is valid when an event loop input is presently dispatching.
     EventLoopInputData m_currentWork;
     // Whether the dispatcher is currently calling out to an inputs' dispatch() method.
-    bool m_dispatching;
+    bool m_dispatching {false};
     // Whether the dispatcher is waiting to dispatch or actively dispatching inputs.
-    bool m_running;
+    bool m_running {false};
 
     DispatchSpeed m_speed;
     // The time at which the last input dispatch() method was called.
-    double m_previousDispatchStartTime;
+    double m_previousDispatchStartTime {0.0};
     // The timestamp specified by the last dispatched input.
-    double m_previousInputTimestamp;
+    double m_previousInputTimestamp {0.0};
 };
 
 } // namespace WebCore
index c8df903..aff46e5 100644 (file)
@@ -43,9 +43,9 @@ namespace WebCore {
 class FunctorInputCursor final : public InputCursor {
     WTF_MAKE_NONCOPYABLE(FunctorInputCursor);
 public:
-    static PassRefPtr<FunctorInputCursor> create(PassRefPtr<ReplaySessionSegment> segment)
+    static Ref<FunctorInputCursor> create(RefPtr<ReplaySessionSegment>&& segment)
     {
-        return adoptRef(new FunctorInputCursor(segment));
+        return adoptRef(*new FunctorInputCursor(WTF::move(segment)));
     }
 
     // InputCursor
@@ -58,9 +58,9 @@ public:
     template<typename Functor>
     typename Functor::ReturnType forEachInputInQueue(InputQueue, Functor&);
 protected:
-    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString&) override;
+    virtual NondeterministicInputBase* loadInput(InputQueue, const String&) override;
 private:
-    FunctorInputCursor(PassRefPtr<ReplaySessionSegment>);
+    FunctorInputCursor(RefPtr<ReplaySessionSegment>&&);
 
     RefPtr<ReplaySessionSegment> m_segment;
 };
@@ -74,8 +74,8 @@ typename Functor::ReturnType FunctorInputCursor::forEachInputInQueue(InputQueue
     return functor.returnValue();
 }
 
-inline FunctorInputCursor::FunctorInputCursor(PassRefPtr<ReplaySessionSegment> segment)
-    : m_segment(segment)
+inline FunctorInputCursor::FunctorInputCursor(RefPtr<ReplaySessionSegment>&& segment)
+    : m_segment(WTF::move(segment))
 {
 }
 
@@ -84,7 +84,7 @@ inline void FunctorInputCursor::storeInput(std::unique_ptr<NondeterministicInput
     ASSERT_NOT_REACHED();
 }
 
-inline NondeterministicInputBase* FunctorInputCursor::loadInput(InputQueue, const AtomicString&)
+inline NondeterministicInputBase* FunctorInputCursor::loadInput(InputQueue, const String&)
 {
     ASSERT_NOT_REACHED();
     return nullptr;
index 0457f8e..0764296 100644 (file)
@@ -113,10 +113,8 @@ static const char* segmentStateToString(SegmentState state)
 
 ReplayController::ReplayController(Page& page)
     : m_page(page)
-    , m_loadedSegment(nullptr)
     , m_loadedSession(ReplaySession::create())
     , m_emptyCursor(EmptyInputCursor::create())
-    , m_activeCursor(nullptr)
     , m_targetPosition(ReplayPosition(0, 0))
     , m_currentPosition(ReplayPosition(0, 0))
     , m_segmentState(SegmentState::Unloaded)
@@ -127,7 +125,7 @@ ReplayController::ReplayController(Page& page)
 
 void ReplayController::setForceDeterministicSettings(bool shouldForceDeterministicBehavior)
 {
-    ASSERT(shouldForceDeterministicBehavior ^ (m_sessionState == SessionState::Inactive));
+    ASSERT_ARG(shouldForceDeterministicBehavior, shouldForceDeterministicBehavior ^ (m_sessionState == SessionState::Inactive));
 
     if (shouldForceDeterministicBehavior) {
         m_savedSettings.usesPageCache = m_page.settings().usesPageCache();
@@ -145,7 +143,7 @@ void ReplayController::setForceDeterministicSettings(bool shouldForceDeterminist
 
 void ReplayController::setSessionState(SessionState state)
 {
-    ASSERT(state != m_sessionState);
+    ASSERT_ARG(state, state != m_sessionState);
 
     LOG(WebReplay, "%-20s SessionState transition: %10s --> %10s.\n", "ReplayController", sessionStateToString(m_sessionState), sessionStateToString(state));
 
@@ -173,7 +171,7 @@ void ReplayController::setSessionState(SessionState state)
 
 void ReplayController::setSegmentState(SegmentState state)
 {
-    ASSERT(state != m_segmentState);
+    ASSERT_ARG(state, state != m_segmentState);
 
     LOG(WebReplay, "%-20s SegmentState transition: %10s --> %10s.\n", "ReplayController", segmentStateToString(m_segmentState), segmentStateToString(state));
 
@@ -198,8 +196,9 @@ void ReplayController::setSegmentState(SegmentState state)
     m_segmentState = state;
 }
 
-void ReplayController::switchSession(PassRefPtr<ReplaySession> session)
+void ReplayController::switchSession(RefPtr<ReplaySession>&& session)
 {
+    ASSERT_ARG(session, session);
     ASSERT(m_segmentState == SegmentState::Unloaded);
     ASSERT(m_sessionState == SessionState::Inactive);
 
@@ -225,7 +224,7 @@ void ReplayController::createSegment()
     LOG(WebReplay, "%-20s Created segment: %p.\n", "ReplayController", m_loadedSegment.get());
     InspectorInstrumentation::segmentCreated(m_page, m_loadedSegment.copyRef());
 
-    m_activeCursor = CapturingInputCursor::create(m_loadedSegment);
+    m_activeCursor = CapturingInputCursor::create(m_loadedSegment.copyRef());
     m_activeCursor->appendInput<BeginSegmentSentinel>();
 
     std::unique_ptr<InitialNavigation> navigationInput = InitialNavigation::createFromPage(m_page);
@@ -249,13 +248,13 @@ void ReplayController::completeSegment()
     LOG(WebReplay, "%-20s Completed segment: %p.\n", "ReplayController", segment.get());
     InspectorInstrumentation::segmentCompleted(m_page, segment.copyRef());
 
-    m_loadedSession->appendSegment(segment);
+    m_loadedSession->appendSegment(segment.copyRef());
     InspectorInstrumentation::sessionModified(m_page, m_loadedSession.copyRef());
 }
 
 void ReplayController::loadSegmentAtIndex(size_t segmentIndex)
 {
-    ASSERT(segmentIndex < m_loadedSession->size());
+    ASSERT_ARG(segmentIndex, segmentIndex >= 0 && segmentIndex < m_loadedSession->size());
     RefPtr<ReplaySessionSegment> segment = m_loadedSession->at(segmentIndex);
 
     ASSERT(m_sessionState == SessionState::Replaying);
@@ -269,7 +268,7 @@ void ReplayController::loadSegmentAtIndex(size_t segmentIndex)
     m_currentPosition.segmentOffset = segmentIndex;
     m_currentPosition.inputOffset = 0;
 
-    m_activeCursor = ReplayingInputCursor::create(m_loadedSegment, m_page, this);
+    m_activeCursor = ReplayingInputCursor::create(m_loadedSegment.copyRef(), m_page, this);
 
     LOG(WebReplay, "%-20sLoading segment: %p.\n", "ReplayController", segment.get());
     InspectorInstrumentation::segmentLoaded(m_page, segment.copyRef());
@@ -287,8 +286,8 @@ void ReplayController::unloadSegment(bool suppressNotifications)
     m_activeCursor = nullptr;
     RefPtr<ReplaySessionSegment> unloadedSegment = m_loadedSegment.release();
     for (Frame* frame = &m_page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
-        frame->script().globalObject(mainThreadNormalWorld())->setInputCursor(m_emptyCursor);
-        frame->document()->setInputCursor(m_emptyCursor);
+        frame->script().globalObject(mainThreadNormalWorld())->setInputCursor(m_emptyCursor.copyRef());
+        frame->document()->setInputCursor(m_emptyCursor.copyRef());
     }
 
     // When we stop capturing, don't send out segment unloaded events since we
@@ -407,7 +406,8 @@ void ReplayController::replayToPosition(const ReplayPosition& position, Dispatch
 void ReplayController::frameNavigated(DocumentLoader* loader)
 {
     ASSERT(m_sessionState != SessionState::Inactive);
-
+    ASSERT_ARG(loader, loader);
+    
     // The initial capturing segment is created prior to main frame navigation.
     // Otherwise, the prior capturing segment was completed when the frame detached,
     // and it is now time to create a new segment.
@@ -478,27 +478,26 @@ void ReplayController::willDispatchEvent(const Event& event, Frame* frame)
 #endif
 }
 
-PassRefPtr<ReplaySession> ReplayController::loadedSession() const
+RefPtr<ReplaySession> ReplayController::loadedSession() const
 {
-    return m_loadedSession;
+    return m_loadedSession.copyRef();
 }
 
-PassRefPtr<ReplaySessionSegment> ReplayController::loadedSegment() const
+RefPtr<ReplaySessionSegment> ReplayController::loadedSegment() const
 {
-    return m_loadedSegment;
+    return m_loadedSegment.copyRef();
 }
 
-InputCursor& ReplayController::activeInputCursor() const
+InputCursor& ReplayController::activeInputCursor()
 {
-    return m_activeCursor ? *m_activeCursor : *m_emptyCursor;
+    return m_activeCursor ? *m_activeCursor : m_emptyCursor.get();
 }
 
 EventLoopInputDispatcher& ReplayController::dispatcher() const
 {
     ASSERT(m_sessionState == SessionState::Replaying);
     ASSERT(m_segmentState == SegmentState::Dispatching);
-    ASSERT(m_activeCursor);
-    ASSERT(m_activeCursor->isReplaying());
+    ASSERT(m_activeCursor && m_activeCursor->isReplaying());
 
     return static_cast<ReplayingInputCursor&>(*m_activeCursor).dispatcher();
 }
index 5e0796d..065a494 100644 (file)
@@ -128,7 +128,7 @@ public:
         replayToPosition(ReplayPosition(), speed);
     }
 
-    void switchSession(PassRefPtr<ReplaySession>);
+    void switchSession(RefPtr<ReplaySession>&&);
 
     // InspectorReplayAgent notifications.
     void frameNavigated(DocumentLoader*);
@@ -140,10 +140,10 @@ public:
     SessionState sessionState() const { return m_sessionState; }
     SegmentState segmentState() const { return m_segmentState; }
 
-    PassRefPtr<ReplaySession> loadedSession() const;
-    PassRefPtr<ReplaySessionSegment> loadedSegment() const;
+    RefPtr<ReplaySession> loadedSession() const;
+    RefPtr<ReplaySessionSegment> loadedSegment() const;
 
-    JSC::InputCursor& activeInputCursor() const;
+    JSC::InputCursor& activeInputCursor();
     ReplayPosition currentPosition() const { return m_currentPosition; }
 
 private:
@@ -176,7 +176,7 @@ private:
 
     RefPtr<ReplaySessionSegment> m_loadedSegment;
     RefPtr<ReplaySession> m_loadedSession;
-    const RefPtr<JSC::InputCursor> m_emptyCursor;
+    Ref<JSC::InputCursor> m_emptyCursor;
     // The active cursor is set to nullptr when invalid.
     RefPtr<JSC::InputCursor> m_activeCursor;
 
index d448b19..f371d1e 100644 (file)
@@ -37,9 +37,9 @@ namespace WebCore {
 
 static unsigned s_nextIdentifier = 1;
 
-PassRefPtr<ReplaySession> ReplaySession::create()
+Ref<ReplaySession> ReplaySession::create()
 {
-    return adoptRef(new ReplaySession());
+    return adoptRef(*new ReplaySession());
 }
 
 ReplaySession::ReplaySession()
@@ -52,35 +52,39 @@ ReplaySession::~ReplaySession()
 {
 }
 
-PassRefPtr<ReplaySessionSegment> ReplaySession::at(size_t position) const
+RefPtr<ReplaySessionSegment> ReplaySession::at(size_t position) const
 {
-    return m_segments.at(position);
+    ASSERT_ARG(position, position >= 0 && position < m_segments.size());
+
+    return m_segments.at(position).copyRef();
 }
 
-void ReplaySession::appendSegment(PassRefPtr<ReplaySessionSegment> prpSegment)
+void ReplaySession::appendSegment(RefPtr<ReplaySessionSegment>&& segment)
 {
-    RefPtr<ReplaySessionSegment> segment = prpSegment;
-
+    ASSERT_ARG(segment, segment);
     // For now, only support one segment.
     ASSERT(!m_segments.size());
 
     // Since replay locations are specified with segment IDs, we can only
     // have one instance of a segment in the session.
-    size_t offset = m_segments.find(segment);
+    size_t offset = m_segments.find(segment.copyRef());
     ASSERT_UNUSED(offset, offset == notFound);
 
-    m_segments.append(segment.release());
+    m_segments.append(WTF::move(segment));
 }
 
-void ReplaySession::insertSegment(size_t position, PassRefPtr<ReplaySessionSegment> segment)
+void ReplaySession::insertSegment(size_t position, RefPtr<ReplaySessionSegment>&& segment)
 {
-    ASSERT(position < m_segments.size());
-    m_segments.insert(position, segment);
+    ASSERT_ARG(segment, segment);
+    ASSERT_ARG(position, position >= 0 && position < m_segments.size());
+
+    m_segments.insert(position, WTF::move(segment));
 }
 
 void ReplaySession::removeSegment(size_t position)
 {
-    ASSERT(position < m_segments.size());
+    ASSERT_ARG(position, position >= 0 && position < m_segments.size());
+
     m_segments.remove(position);
 }
 
index fec81b4..866e6f5 100644 (file)
@@ -43,20 +43,20 @@ typedef Vector<RefPtr<ReplaySessionSegment>>::const_iterator SegmentIterator;
 class ReplaySession : public RefCounted<ReplaySession> {
     WTF_MAKE_NONCOPYABLE(ReplaySession);
 public:
-    static PassRefPtr<ReplaySession> create();
+    static Ref<ReplaySession> create();
     ~ReplaySession();
 
     double timestamp() const { return m_timestamp; }
     unsigned identifier() const { return m_identifier; }
 
     size_t size() const { return m_segments.size(); }
-    PassRefPtr<ReplaySessionSegment> at(size_t position) const;
+    RefPtr<ReplaySessionSegment> at(size_t position) const;
 
     SegmentIterator begin() const { return m_segments.begin(); }
     SegmentIterator end() const { return m_segments.end(); }
 
-    void appendSegment(PassRefPtr<ReplaySessionSegment>);
-    void insertSegment(size_t position, PassRefPtr<ReplaySessionSegment>);
+    void appendSegment(RefPtr<ReplaySessionSegment>&&);
+    void insertSegment(size_t position, RefPtr<ReplaySessionSegment>&&);
     void removeSegment(size_t position);
 
 private:
index b90e88f..54b7b1c 100644 (file)
 #include "ReplayingInputCursor.h"
 #include "SegmentedInputStorage.h"
 #include <wtf/CurrentTime.h>
-#include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
 static unsigned s_nextSegmentIdentifier = 1;
 
-PassRefPtr<ReplaySessionSegment> ReplaySessionSegment::create()
+Ref<ReplaySessionSegment> ReplaySessionSegment::create()
 {
-    return adoptRef(new ReplaySessionSegment);
+    return adoptRef(*new ReplaySessionSegment);
 }
 
 ReplaySessionSegment::ReplaySessionSegment()
     : m_storage(std::make_unique<SegmentedInputStorage>())
     , m_identifier(s_nextSegmentIdentifier++)
-    , m_canCapture(true)
     , m_timestamp(currentTimeMS())
 {
 }
index 5d45041..8e785a9 100644 (file)
@@ -48,7 +48,7 @@ friend class CapturingInputCursor;
 friend class FunctorInputCursor;
 friend class ReplayingInputCursor;
 public:
-    static PassRefPtr<ReplaySessionSegment> create();
+    static Ref<ReplaySessionSegment> create();
     ~ReplaySessionSegment();
 
     unsigned identifier() const { return m_identifier; }
@@ -64,7 +64,7 @@ private:
     Vector<double, 0> m_eventLoopTimings;
 
     unsigned m_identifier;
-    bool m_canCapture;
+    bool m_canCapture {true};
     double m_timestamp;
 };
 
index 8822ee5..6ca7503 100644 (file)
@@ -39,8 +39,8 @@
 
 namespace WebCore {
 
-ReplayingInputCursor::ReplayingInputCursor(PassRefPtr<ReplaySessionSegment> segment, Page& page, EventLoopInputDispatcherClient* client)
-    : m_segment(segment)
+ReplayingInputCursor::ReplayingInputCursor(RefPtr<ReplaySessionSegment>&& segment, Page& page, EventLoopInputDispatcherClient* client)
+    : m_segment(WTF::move(segment))
     , m_dispatcher(std::make_unique<EventLoopInputDispatcher>(page, *this, client))
 {
     for (size_t i = 0; i < static_cast<size_t>(InputQueue::Count); i++)
@@ -51,9 +51,9 @@ ReplayingInputCursor::~ReplayingInputCursor()
 {
 }
 
-PassRefPtr<ReplayingInputCursor> ReplayingInputCursor::create(PassRefPtr<ReplaySessionSegment> segment, Page& page, EventLoopInputDispatcherClient* client)
+Ref<ReplayingInputCursor> ReplayingInputCursor::create(RefPtr<ReplaySessionSegment>&& segment, Page& page, EventLoopInputDispatcherClient* client)
 {
-    return adoptRef(new ReplayingInputCursor(segment, page, client));
+    return adoptRef(*new ReplayingInputCursor(WTF::move(segment), page, client));
 }
 
 void ReplayingInputCursor::storeInput(std::unique_ptr<NondeterministicInputBase>)
@@ -62,12 +62,12 @@ void ReplayingInputCursor::storeInput(std::unique_ptr<NondeterministicInputBase>
     ASSERT_NOT_REACHED();
 }
 
-NondeterministicInputBase* ReplayingInputCursor::loadInput(InputQueue queue, const AtomicString& type)
+NondeterministicInputBase* ReplayingInputCursor::loadInput(InputQueue queue, const String& type)
 {
     NondeterministicInputBase* input = uncheckedLoadInput(queue);
 
     if (input->type() != type) {
-        LOG_ERROR("%-25s ERROR: Expected replay input of type %s, but got type %s\n", "[ReplayingInputCursor]", type.string().ascii().data(), input->type().ascii().data());
+        LOG_ERROR("%-25s ERROR: Expected replay input of type %s, but got type %s\n", "[ReplayingInputCursor]", type.ascii().data(), input->type().ascii().data());
         return nullptr;
     }
 
index 9c71f41..e0a6aad 100644 (file)
@@ -32,7 +32,6 @@
 
 #include <replay/InputCursor.h>
 #include <wtf/Vector.h>
-#include <wtf/text/AtomicString.h>
 
 namespace WebCore {
 
@@ -50,7 +49,7 @@ struct EventLoopInputData {
 class ReplayingInputCursor final : public InputCursor {
     WTF_MAKE_NONCOPYABLE(ReplayingInputCursor);
 public:
-    static PassRefPtr<ReplayingInputCursor> create(PassRefPtr<ReplaySessionSegment>, Page&, EventLoopInputDispatcherClient*);
+    static Ref<ReplayingInputCursor> create(RefPtr<ReplaySessionSegment>&&, Page&, EventLoopInputDispatcherClient*);
     virtual ~ReplayingInputCursor();
 
     virtual bool isCapturing() const override { return false; }
@@ -60,9 +59,9 @@ public:
 
     EventLoopInputData loadEventLoopInput();
 protected:
-    virtual NondeterministicInputBase* loadInput(InputQueue, const AtomicString& type) override;
+    virtual NondeterministicInputBase* loadInput(InputQueue, const String& type) override;
 private:
-    ReplayingInputCursor(PassRefPtr<ReplaySessionSegment>, Page&, EventLoopInputDispatcherClient*);
+    ReplayingInputCursor(RefPtr<ReplaySessionSegment>&&, Page&, EventLoopInputDispatcherClient*);
 
     virtual void storeInput(std::unique_ptr<NondeterministicInputBase>) override;
     virtual NondeterministicInputBase* uncheckedLoadInput(InputQueue) override;
index 93fee8c..214249b 100644 (file)
@@ -74,7 +74,6 @@ static size_t offsetForInputQueue(InputQueue inputQueue)
 }
 
 SegmentedInputStorage::SegmentedInputStorage()
-    : m_inputCount(0)
 {
     for (size_t i = 0; i < offsetForInputQueue(InputQueue::Count); i++)
         m_queues.append(new QueuedInputs);
@@ -100,8 +99,8 @@ NondeterministicInputBase* SegmentedInputStorage::load(InputQueue inputQueue, si
 
 void SegmentedInputStorage::store(std::unique_ptr<NondeterministicInputBase> input)
 {
-    ASSERT(input);
-    ASSERT(input->queue() < InputQueue::Count);
+    ASSERT_ARG(input, input);
+    ASSERT_ARG(input, input->queue() < InputQueue::Count);
 
     LOG(WebReplay, "%-14s#%-5u %s: %s %s\n", "ReplayEvents", m_inputCount++, queueTypeToLogPrefix(input->queue(), false), input->type().utf8().data(), jsonStringForInput(*input).utf8().data());
 
@@ -115,7 +114,7 @@ size_t SegmentedInputStorage::queueSize(InputQueue inputQueue) const
 
 const SegmentedInputStorage::QueuedInputs& SegmentedInputStorage::queue(InputQueue queue) const
 {
-    ASSERT(queue < InputQueue::Count);
+    ASSERT_ARG(queue, queue < InputQueue::Count);
     return *m_queues.at(offsetForInputQueue(queue));
 }
 
index b87211b..074f964 100644 (file)
@@ -52,7 +52,7 @@ private:
     const QueuedInputs& queue(InputQueue) const;
 
     Vector<QueuedInputs*, 3> m_queues;
-    unsigned m_inputCount;
+    unsigned m_inputCount {0};
 };
 
 } // namespace WebCore