| Index: Source/bindings/core/v8/ScriptStreamer.h
 | 
| diff --git a/Source/bindings/core/v8/ScriptStreamer.h b/Source/bindings/core/v8/ScriptStreamer.h
 | 
| index c61e1337c796281606fc7a327a178078222dd4d3..9341871b3b5074875d150b8a1aa2c09bcc6710eb 100644
 | 
| --- a/Source/bindings/core/v8/ScriptStreamer.h
 | 
| +++ b/Source/bindings/core/v8/ScriptStreamer.h
 | 
| @@ -5,6 +5,7 @@
 | 
|  #ifndef ScriptStreamer_h
 | 
|  #define ScriptStreamer_h
 | 
|  
 | 
| +#include "bindings/core/v8/ScriptStreamingMode.h"
 | 
|  #include "core/dom/PendingScript.h"
 | 
|  #include "wtf/RefCounted.h"
 | 
|  
 | 
| @@ -82,7 +83,7 @@ public:
 | 
|  
 | 
|      // Called by ScriptStreamingTask when it has streamed all data to V8 and V8
 | 
|      // has processed it.
 | 
| -    void streamingComplete();
 | 
| +    void streamingCompleteOnBackgroundThread();
 | 
|  
 | 
|      static void setSmallScriptThresholdForTesting(size_t threshold)
 | 
|      {
 | 
| @@ -96,10 +97,16 @@ private:
 | 
|      // streamed. Non-const for testing.
 | 
|      static size_t kSmallScriptThreshold;
 | 
|  
 | 
| -    ScriptStreamer(ScriptResource*, v8::ScriptCompiler::StreamedSource::Encoding, PendingScript::Type);
 | 
| +    ScriptStreamer(ScriptResource*, v8::ScriptCompiler::StreamedSource::Encoding, PendingScript::Type, ScriptStreamingMode);
 | 
|  
 | 
| +    void streamingComplete();
 | 
|      void notifyFinishedToClient();
 | 
|  
 | 
| +    bool shouldBlockMainThread() const
 | 
| +    {
 | 
| +        return m_scriptStreamingMode == ScriptStreamingModeAllPlusBlockParsingBlocking && m_scriptType == PendingScript::ParsingBlocking;
 | 
| +    }
 | 
| +
 | 
|      static const char* startedStreamingHistogramName(PendingScript::Type);
 | 
|  
 | 
|      static bool startStreamingInternal(PendingScript&, Settings*, ScriptState*, PendingScript::Type);
 | 
| @@ -118,12 +125,14 @@ private:
 | 
|      ScriptResourceClient* m_client;
 | 
|      WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_task;
 | 
|      bool m_loadingFinished; // Whether loading from the network is done.
 | 
| -    bool m_parsingFinished; // Whether the V8 side processing is done.
 | 
| +    // Whether the V8 side processing is done. Will be used by the main thread
 | 
| +    // and the streamer thread; guarded by m_mutex.
 | 
| +    bool m_parsingFinished;
 | 
|      // Whether we have received enough data to start the streaming.
 | 
|      bool m_haveEnoughDataForStreaming;
 | 
|  
 | 
|      // Whether the script source code should be retrieved from the Resource
 | 
| -    // instead of the ScriptStreamer.
 | 
| +    // instead of the ScriptStreamer; guarded by m_mutex.
 | 
|      bool m_streamingSuppressed;
 | 
|  
 | 
|      // What kind of cached data V8 produces during streaming.
 | 
| @@ -131,6 +140,18 @@ private:
 | 
|  
 | 
|      // For recording metrics for different types of scripts separately.
 | 
|      PendingScript::Type m_scriptType;
 | 
| +
 | 
| +    // Streaming mode defines whether the main thread should block and wait for
 | 
| +    // the parsing to complete after the load has finished. See
 | 
| +    // ScriptStreamer::notifyFinished for more information.
 | 
| +    ScriptStreamingMode m_scriptStreamingMode;
 | 
| +    Mutex m_mutex;
 | 
| +    ThreadCondition m_parsingFinishedCondition;
 | 
| +    // Whether the main thread is currently waiting on the parser thread in
 | 
| +    // notifyFinished(). This also defines which thread should do the cleanup of
 | 
| +    // the parsing task: if the main thread is waiting, the main thread should
 | 
| +    // do it, otherwise the parser thread should do it. Guarded by m_mutex.
 | 
| +    bool m_mainThreadWaitingForParserThread;
 | 
|  };
 | 
|  
 | 
|  } // namespace blink
 | 
| 
 |