| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 RefPtr<TypeBuilder::Array<TypeBuilder::Page::Cookie> > cookies = TypeBuilder
::Array<TypeBuilder::Page::Cookie>::create(); | 573 RefPtr<TypeBuilder::Array<TypeBuilder::Page::Cookie> > cookies = TypeBuilder
::Array<TypeBuilder::Page::Cookie>::create(); |
| 574 | 574 |
| 575 ListHashSet<Cookie>::iterator end = cookiesList.end(); | 575 ListHashSet<Cookie>::iterator end = cookiesList.end(); |
| 576 ListHashSet<Cookie>::iterator it = cookiesList.begin(); | 576 ListHashSet<Cookie>::iterator it = cookiesList.begin(); |
| 577 for (int i = 0; it != end; ++it, i++) | 577 for (int i = 0; it != end; ++it, i++) |
| 578 cookies->addItem(buildObjectForCookie(*it)); | 578 cookies->addItem(buildObjectForCookie(*it)); |
| 579 | 579 |
| 580 return cookies; | 580 return cookies; |
| 581 } | 581 } |
| 582 | 582 |
| 583 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult) | 583 static void cachedResourcesForDocument(Document* document, Vector<Resource*>& re
sult, bool skipXHRs) |
| 584 { | 584 { |
| 585 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); | 585 const ResourceFetcher::DocumentResourceMap& allResources = document->fetcher
()->allResources(); |
| 586 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); | 586 ResourceFetcher::DocumentResourceMap::const_iterator end = allResources.end(
); |
| 587 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { | 587 for (ResourceFetcher::DocumentResourceMap::const_iterator it = allResources.
begin(); it != end; ++it) { |
| 588 Resource* cachedResource = it->value.get(); | 588 Resource* cachedResource = it->value.get(); |
| 589 | 589 |
| 590 switch (cachedResource->type()) { | 590 switch (cachedResource->type()) { |
| 591 case Resource::Image: | 591 case Resource::Image: |
| 592 // Skip images that were not auto loaded (images disabled in the use
r agent). | 592 // Skip images that were not auto loaded (images disabled in the use
r agent). |
| 593 if (toImageResource(cachedResource)->stillNeedsLoad()) | 593 if (toImageResource(cachedResource)->stillNeedsLoad()) |
| 594 continue; | 594 continue; |
| 595 break; | 595 break; |
| 596 case Resource::Font: | 596 case Resource::Font: |
| 597 // Skip fonts that were referenced in CSS but never used/downloaded. | 597 // Skip fonts that were referenced in CSS but never used/downloaded. |
| 598 if (toFontResource(cachedResource)->stillNeedsLoad()) | 598 if (toFontResource(cachedResource)->stillNeedsLoad()) |
| 599 continue; | 599 continue; |
| 600 break; | 600 break; |
| 601 case Resource::Raw: |
| 602 if (skipXHRs) |
| 603 continue; |
| 604 break; |
| 601 default: | 605 default: |
| 602 // All other Resource types download immediately. | 606 // All other Resource types download immediately. |
| 603 break; | 607 break; |
| 604 } | 608 } |
| 605 | 609 |
| 606 result.append(cachedResource); | 610 result.append(cachedResource); |
| 607 } | 611 } |
| 608 } | 612 } |
| 609 | 613 |
| 610 // static | 614 // static |
| 611 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) | 615 Vector<Document*> InspectorPageAgent::importsForFrame(LocalFrame* frame) |
| 612 { | 616 { |
| 613 Vector<Document*> result; | 617 Vector<Document*> result; |
| 614 Document* rootDocument = frame->document(); | 618 Document* rootDocument = frame->document(); |
| 615 | 619 |
| 616 if (HTMLImportsController* controller = rootDocument->importsController()) { | 620 if (HTMLImportsController* controller = rootDocument->importsController()) { |
| 617 for (size_t i = 0; i < controller->loaderCount(); ++i) { | 621 for (size_t i = 0; i < controller->loaderCount(); ++i) { |
| 618 if (Document* document = controller->loaderAt(i)->document()) | 622 if (Document* document = controller->loaderAt(i)->document()) |
| 619 result.append(document); | 623 result.append(document); |
| 620 } | 624 } |
| 621 } | 625 } |
| 622 | 626 |
| 623 return result; | 627 return result; |
| 624 } | 628 } |
| 625 | 629 |
| 626 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame) | 630 static Vector<Resource*> cachedResourcesForFrame(LocalFrame* frame, bool skipXHR
s) |
| 627 { | 631 { |
| 628 Vector<Resource*> result; | 632 Vector<Resource*> result; |
| 629 Document* rootDocument = frame->document(); | 633 Document* rootDocument = frame->document(); |
| 630 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); | 634 Vector<Document*> loaders = InspectorPageAgent::importsForFrame(frame); |
| 631 | 635 |
| 632 cachedResourcesForDocument(rootDocument, result); | 636 cachedResourcesForDocument(rootDocument, result, skipXHRs); |
| 633 for (size_t i = 0; i < loaders.size(); ++i) | 637 for (size_t i = 0; i < loaders.size(); ++i) |
| 634 cachedResourcesForDocument(loaders[i], result); | 638 cachedResourcesForDocument(loaders[i], result, skipXHRs); |
| 635 | 639 |
| 636 return result; | 640 return result; |
| 637 } | 641 } |
| 638 | 642 |
| 639 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) | 643 static Vector<KURL> allResourcesURLsForFrame(LocalFrame* frame) |
| 640 { | 644 { |
| 641 Vector<KURL> result; | 645 Vector<KURL> result; |
| 642 | 646 |
| 643 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); | 647 result.append(urlWithoutFragment(frame->loader().documentLoader()->url())); |
| 644 | 648 |
| 645 Vector<Resource*> allResources = cachedResourcesForFrame(frame); | 649 Vector<Resource*> allResources = cachedResourcesForFrame(frame, false); |
| 646 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) | 650 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) |
| 647 result.append(urlWithoutFragment((*it)->url())); | 651 result.append(urlWithoutFragment((*it)->url())); |
| 648 | 652 |
| 649 return result; | 653 return result; |
| 650 } | 654 } |
| 651 | 655 |
| 652 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) | 656 void InspectorPageAgent::getCookies(ErrorString*, RefPtr<TypeBuilder::Array<Type
Builder::Page::Cookie> >& cookies) |
| 653 { | 657 { |
| 654 ListHashSet<Cookie> rawCookiesList; | 658 ListHashSet<Cookie> rawCookiesList; |
| 655 | 659 |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 } | 1238 } |
| 1235 | 1239 |
| 1236 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) | 1240 PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject
ForFrameTree(LocalFrame* frame) |
| 1237 { | 1241 { |
| 1238 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); | 1242 RefPtr<TypeBuilder::Page::Frame> frameObject = buildObjectForFrame(frame); |
| 1239 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); | 1243 RefPtr<TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resources> >
subresources = TypeBuilder::Array<TypeBuilder::Page::FrameResourceTree::Resourc
es>::create(); |
| 1240 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() | 1244 RefPtr<TypeBuilder::Page::FrameResourceTree> result = TypeBuilder::Page::Fra
meResourceTree::create() |
| 1241 .setFrame(frameObject) | 1245 .setFrame(frameObject) |
| 1242 .setResources(subresources); | 1246 .setResources(subresources); |
| 1243 | 1247 |
| 1244 Vector<Resource*> allResources = cachedResourcesForFrame(frame); | 1248 Vector<Resource*> allResources = cachedResourcesForFrame(frame, true); |
| 1245 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { | 1249 for (Vector<Resource*>::const_iterator it = allResources.begin(); it != allR
esources.end(); ++it) { |
| 1246 Resource* cachedResource = *it; | 1250 Resource* cachedResource = *it; |
| 1247 | 1251 |
| 1248 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() | 1252 RefPtr<TypeBuilder::Page::FrameResourceTree::Resources> resourceObject =
TypeBuilder::Page::FrameResourceTree::Resources::create() |
| 1249 .setUrl(urlWithoutFragment(cachedResource->url()).string()) | 1253 .setUrl(urlWithoutFragment(cachedResource->url()).string()) |
| 1250 .setType(cachedResourceTypeJson(*cachedResource)) | 1254 .setType(cachedResourceTypeJson(*cachedResource)) |
| 1251 .setMimeType(cachedResource->response().mimeType()); | 1255 .setMimeType(cachedResource->response().mimeType()); |
| 1252 if (cachedResource->wasCanceled()) | 1256 if (cachedResource->wasCanceled()) |
| 1253 resourceObject->setCanceled(true); | 1257 resourceObject->setCanceled(true); |
| 1254 else if (cachedResource->status() == Resource::LoadError) | 1258 else if (cachedResource->status() == Resource::LoadError) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1428 bool InspectorPageAgent::getEditedResourceContent(const String& url, String* con
tent) | 1432 bool InspectorPageAgent::getEditedResourceContent(const String& url, String* con
tent) |
| 1429 { | 1433 { |
| 1430 if (!m_editedResourceContent.contains(url)) | 1434 if (!m_editedResourceContent.contains(url)) |
| 1431 return false; | 1435 return false; |
| 1432 *content = m_editedResourceContent.get(url); | 1436 *content = m_editedResourceContent.get(url); |
| 1433 return true; | 1437 return true; |
| 1434 } | 1438 } |
| 1435 | 1439 |
| 1436 } // namespace WebCore | 1440 } // namespace WebCore |
| 1437 | 1441 |
| OLD | NEW |