1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_SVG_RESOURCE_H_ 6 #define THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_SVG_RESOURCE_H_ 7 8 #include "base/macros.h" 9 #include "base/memory/scoped_refptr.h" 10 #include "third_party/blink/renderer/core/svg/svg_resource.h" 11 #include "third_party/blink/renderer/platform/heap/persistent.h" 12 #include "third_party/blink/renderer/platform/wtf/allocator/allocator.h" 13 #include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" 14 15 namespace blink { 16 17 class StyleSVGResource : public RefCounted<StyleSVGResource> { 18 USING_FAST_MALLOC(StyleSVGResource); 19 20 public: Create(SVGResource * resource,const AtomicString & url)21 static scoped_refptr<StyleSVGResource> Create(SVGResource* resource, 22 const AtomicString& url) { 23 return base::AdoptRef(new StyleSVGResource(resource, url)); 24 } 25 26 bool operator==(const StyleSVGResource& other) const { 27 return resource_.Get() == other.resource_.Get(); 28 } 29 AddClient(SVGResourceClient & client)30 void AddClient(SVGResourceClient& client) { 31 if (resource_) 32 resource_->AddClient(client); 33 } RemoveClient(SVGResourceClient & client)34 void RemoveClient(SVGResourceClient& client) { 35 if (resource_) 36 resource_->RemoveClient(client); 37 } 38 Resource()39 SVGResource* Resource() const { return resource_; } Url()40 const AtomicString& Url() const { return url_; } 41 42 private: StyleSVGResource(SVGResource * resource,const AtomicString & url)43 StyleSVGResource(SVGResource* resource, const AtomicString& url) 44 : resource_(resource), url_(url) {} 45 46 Persistent<SVGResource> resource_; 47 const AtomicString url_; 48 49 DISALLOW_COPY_AND_ASSIGN(StyleSVGResource); 50 }; 51 52 } // namespace blink 53 54 #endif // THIRD_PARTY_BLINK_RENDERER_CORE_STYLE_STYLE_SVG_RESOURCE_H_ 55