public void NotifyContentItemParsed(ContentItem ci) { lock (this) { m_IsReady.Enqueue(ci); m_SignalReady.Set(); } }
public Xhr(ContentItem ci) { ContentItem = ci; XhrEvents = new List<XhrEvent>(); }
public Script(string unresolvedName, bool isTopLevelEval, ContentItem ci) : this(unresolvedName, ci) { IsTopLevelEval = isTopLevelEval; }
public Script(string unresolvedName, ContentItem ci) { Name = unresolvedName; DefinitionContentItem = ci; }
// Scripts private void HandleScriptCreated(string message, Func<string> getNextMessage) { bool parseHolder = false; string[] parts = message.Split(new char[] { ',' }, 8); int id = int.Parse(parts[1]); string name = parts[2]; string startInfo = parts[3]; string endInfo = parts[4]; int deltaLine = int.Parse(parts[5]); int xhrId; bool hasXhrId = int.TryParse(parts[6], out xhrId); string url = parts[7]; if (m_ScriptPage.HasScriptWithId(id)) throw new ApplicationException("Cannot define script more than once."); string nextMessage = getNextMessage(); if (!nextMessage.StartsWith("SCRIPT-SOURCE,")) throw new ApplicationException("Script source expected."); parts = nextMessage.Split(new char[] { ',' }, 3); string desc = parts[1]; string src = parts[2]; Script s; if (url != "" && url != "<eval>" && m_ScriptPage.HasContentItemWithUrl(url)) { // Small TODO: There might have been duplicate requests for the same url, returning different data. // Instead of the url, our firefox plugin should give us something more accurate. s = new Script(name, m_ScriptPage.GetContentItemByUrl(url)); } else { bool isEval = url == "<eval>"; if (m_ScriptSourceHolder == null) { if (hasXhrId) { m_ScriptSourceHolder = m_ScriptPage.GetContentItemById(xhrId); m_ScriptSourceHolder.OverrideMimeType("text/javascript"); } else { SimpleUri u = isEval ? new SimpleUri("") : new SimpleUri(url); m_ScriptSourceHolder = new ContentItem(m_ScriptPage, null) { Url = u, MimeType = "text/javascript", IsXhr = false }; } } bool isTopLevelEval = desc == "src" && isEval; if (desc == "src") { if (hasXhrId) { if (new TextDocument(src).FullText != m_ScriptSourceHolder.Document.FullText) throw new ApplicationException("Hash sanity check failed."); } else { m_ScriptSourceHolder.Document = new TextDocument(src); } parseHolder = true; } if (isEval && name == "") name = "<toplevel>"; s = new Script(name, isTopLevelEval, m_ScriptSourceHolder); } if (startInfo == "UNKNOWN") { s.SetPosInfoUnknown(); } else if (startInfo == "ALL") { s.SetPosInfoAll(deltaLine); } else if (startInfo.StartsWith("POS;")) { string[] posInfo = startInfo.Split(';'); int startPos = int.Parse(posInfo[1]); int endPos = int.Parse(posInfo[2]); s.SetPosInfo(startPos, endPos, deltaLine); } else { int startLine = int.Parse(startInfo) - 1; int endLine = int.Parse(endInfo) - 1; s.SetLineInfo(startLine, endLine, deltaLine); } m_ScriptPage.AddScript(id, s); m_Resolver.QueueForResolve(s); if (parseHolder) { EnqueueParse(m_ScriptSourceHolder); m_ScriptSourceHolder = null; } }
private void HandleRequest(string message) { string[] parts = message.Split(new char[] { ',' }, 6); int id = int.Parse(parts[1]); long startTime = long.Parse(parts[2]); bool isInitialRequest = parts[3] == "initial"; bool isInitialDuplicateRequest = parts[3] == "initial-duplicate"; bool isXhr = parts[3] == "xhr"; string method = parts[4]; string url = parts[5]; if (isInitialRequest) { HandleNewPageRequest(url); } PageRequest page = (isInitialRequest || isInitialDuplicateRequest) ? m_InitialPage : m_LoadedPage; m_PageRequestById[id] = page; ContentItem ci = new ContentItem(page, new SimpleUri(url)); ci.RequestMethod = method; ci.IsXhr = isXhr; ci.RequestStartTime = startTime; page.AddContentItemWithoutUrl(id, ci); if (isXhr) { if (m_LoadedPage != m_ScriptPage) throw new ApplicationException("Bad xhr call"); m_ScriptPage.AddCallInfoSendXhr(ci); } }
private void HandleNewPageScripts() { m_ScriptPage = m_LoadedPage; m_ScriptSourceHolder = null; }
private void EnqueueParse(ContentItem ci) { ThreadPool.QueueUserWorkItem(new WaitCallback((dummy) => { ci.Parse(); m_Resolver.NotifyContentItemParsed(ci); })); }