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

Side by Side Diff: Source/core/loader/cache/CachedResourceRequest.cpp

Issue 14672042: Prepare to add more initiator info to CachedResource(Request) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google, Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 14 matching lines...) Expand all
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/loader/cache/CachedResourceRequest.h" 27 #include "core/loader/cache/CachedResourceRequest.h"
28 28
29 #include "core/dom/Document.h" 29 #include "core/dom/Document.h"
30 #include "core/dom/Element.h" 30 #include "core/dom/Element.h"
31 #include "core/loader/cache/CachedResourceLoader.h" 31 #include "core/loader/cache/CachedResourceLoader.h"
32 32
33 namespace WebCore { 33 namespace WebCore {
34 34
35 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ est, const String& charset, ResourceLoadPriority priority) 35 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ est, const AtomicString& initiator, const String& charset, ResourceLoadPriority priority)
36 : m_resourceRequest(resourceRequest) 36 : m_resourceRequest(resourceRequest)
37 , m_charset(charset) 37 , m_charset(charset)
38 , m_options(CachedResourceLoader::defaultCachedResourceOptions()) 38 , m_options(CachedResourceLoader::defaultCachedResourceOptions())
39 , m_priority(priority) 39 , m_priority(priority)
40 , m_forPreload(false) 40 , m_forPreload(false)
41 , m_defer(NoDefer) 41 , m_defer(NoDefer)
42 { 42 {
43 m_initiatorInfo.name = initiator;
43 } 44 }
44 45
45 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ est, const ResourceLoaderOptions& options) 46 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ est, const AtomicString& initiator, const ResourceLoaderOptions& options)
46 : m_resourceRequest(resourceRequest) 47 : m_resourceRequest(resourceRequest)
47 , m_options(options) 48 , m_options(options)
48 , m_priority(ResourceLoadPriorityUnresolved) 49 , m_priority(ResourceLoadPriorityUnresolved)
49 , m_forPreload(false) 50 , m_forPreload(false)
50 , m_defer(NoDefer) 51 , m_defer(NoDefer)
51 { 52 {
53 m_initiatorInfo.name = initiator;
52 } 54 }
53 55
54 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ est, ResourceLoadPriority priority) 56 CachedResourceRequest::CachedResourceRequest(const ResourceRequest& resourceRequ est, const AtomicString& initiator, ResourceLoadPriority priority)
55 : m_resourceRequest(resourceRequest) 57 : m_resourceRequest(resourceRequest)
56 , m_options(CachedResourceLoader::defaultCachedResourceOptions()) 58 , m_options(CachedResourceLoader::defaultCachedResourceOptions())
57 , m_priority(priority) 59 , m_priority(priority)
58 , m_forPreload(false) 60 , m_forPreload(false)
59 , m_defer(NoDefer) 61 , m_defer(NoDefer)
60 { 62 {
63 m_initiatorInfo.name = initiator;
61 } 64 }
62 65
63 CachedResourceRequest::~CachedResourceRequest() 66 CachedResourceRequest::~CachedResourceRequest()
64 { 67 {
65 } 68 }
66 69
67 void CachedResourceRequest::setInitiator(PassRefPtr<Element> element)
68 {
69 ASSERT(!m_initiatorElement && m_initiatorName.isEmpty());
70 m_initiatorElement = element;
71 }
72
73 void CachedResourceRequest::setInitiator(const AtomicString& name)
74 {
75 ASSERT(!m_initiatorElement && m_initiatorName.isEmpty());
76 m_initiatorName = name;
77 }
78
79 const AtomicString& CachedResourceRequest::initiatorName() const
80 {
81 if (m_initiatorElement)
82 return m_initiatorElement->localName();
83 if (!m_initiatorName.isEmpty())
84 return m_initiatorName;
85
86 DEFINE_STATIC_LOCAL(AtomicString, defaultName, ("resource", AtomicString::Co nstructFromLiteral));
87 return defaultName;
88 }
89
90 PassRefPtr<Element> CachedResourceRequest::initiatorElement()
91 {
92 return m_initiatorElement;
93 }
94
95 } // namespace WebCore 70 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/cache/CachedResourceRequest.h ('k') | Source/core/loader/cache/CachedResourceRequestInitiators.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698