Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2010 Apple 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 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "core/dom/DOMStringList.h" | 33 #include "core/dom/DOMStringList.h" |
| 34 #include "core/frame/DOMWindowProperty.h" | 34 #include "core/frame/DOMWindowProperty.h" |
| 35 #include "wtf/PassRefPtr.h" | 35 #include "wtf/PassRefPtr.h" |
| 36 #include "wtf/RefCounted.h" | 36 #include "wtf/RefCounted.h" |
| 37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class LocalDOMWindow; | 41 class LocalDOMWindow; |
| 42 class ExceptionState; | 42 class ExceptionState; |
| 43 class LocalFrame; | 43 class Frame; |
| 44 class KURL; | 44 class KURL; |
| 45 | 45 |
| 46 class Location final : public RefCountedWillBeGarbageCollected<Location>, public ScriptWrappable, public DOMWindowProperty { | 46 // This class corresponds to the JS Location API, which is the only DOM API besi des Window that is operable |
| 47 // in a RemoteFrame. Rather than making DOMWindowProperty support RemoteFrames a nd generating a lot | |
| 48 // code churn, Location is implemented as a one-off with some custom lifetime ma nagement code. Namely, | |
| 49 // it needs a manual call to reset() from DOMWindow::reset() to ensure it doesn' t retain a stale Frame pointer. | |
|
dcheng
2015/02/02 21:50:36
Would we still need reset() with Oilpan? I guess w
sof
2015/02/02 22:53:04
We normally keep such Oilpan-specific dispose/rese
haraken
2015/02/03 00:56:09
Right, in order not to make GC's behavior observab
Nate Chapin
2015/02/03 19:17:21
I added an unconditional reset() to ~DOMWindow. I
| |
| 50 class Location final : public RefCountedWillBeGarbageCollected<Location>, public ScriptWrappable { | |
| 47 DEFINE_WRAPPERTYPEINFO(); | 51 DEFINE_WRAPPERTYPEINFO(); |
| 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Location); | 52 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Location); |
| 49 public: | 53 public: |
| 50 static PassRefPtrWillBeRawPtr<Location> create(LocalFrame* frame) | 54 static PassRefPtrWillBeRawPtr<Location> create(Frame* frame) |
| 51 { | 55 { |
| 52 return adoptRefWillBeNoop(new Location(frame)); | 56 return adoptRefWillBeNoop(new Location(frame)); |
| 53 } | 57 } |
| 54 | 58 |
| 59 Frame* frame() const { return m_frame.get(); } | |
| 60 void reset() { m_frame = nullptr; } | |
| 61 | |
| 55 void setHref(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); | 62 void setHref(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); |
| 56 String href() const; | 63 String href() const; |
| 57 | 64 |
| 58 void assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, co nst String&); | 65 void assign(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, co nst String&); |
| 59 void replace(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); | 66 void replace(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); |
| 60 void reload(LocalDOMWindow* callingWindow); | 67 void reload(LocalDOMWindow* callingWindow); |
| 61 | 68 |
| 62 void setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&, ExceptionState&); | 69 void setProtocol(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&, ExceptionState&); |
| 63 String protocol() const; | 70 String protocol() const; |
| 64 void setHost(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); | 71 void setHost(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); |
| 65 String host() const; | 72 String host() const; |
| 66 void setHostname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&); | 73 void setHostname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&); |
| 67 String hostname() const; | 74 String hostname() const; |
| 68 void setPort(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); | 75 void setPort(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); |
| 69 String port() const; | 76 String port() const; |
| 70 void setPathname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&); | 77 void setPathname(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindo w, const String&); |
| 71 String pathname() const; | 78 String pathname() const; |
| 72 void setSearch(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String&); | 79 void setSearch(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, const String&); |
| 73 String search() const; | 80 String search() const; |
| 74 void setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); | 81 void setHash(LocalDOMWindow* callingWindow, LocalDOMWindow* enteredWindow, c onst String&); |
| 75 String hash() const; | 82 String hash() const; |
| 76 String origin() const; | 83 String origin() const; |
| 77 | 84 |
| 78 PassRefPtrWillBeRawPtr<DOMStringList> ancestorOrigins() const; | 85 PassRefPtrWillBeRawPtr<DOMStringList> ancestorOrigins() const; |
| 79 | 86 |
| 80 virtual void trace(Visitor*) override; | 87 virtual void trace(Visitor*); |
| 81 | 88 |
| 82 private: | 89 private: |
| 83 explicit Location(LocalFrame*); | 90 explicit Location(Frame*); |
| 84 | 91 |
| 85 enum class SetLocation { Normal, ReplaceThisFrame }; | 92 enum class SetLocation { Normal, ReplaceThisFrame }; |
| 86 void setLocation(const String&, LocalDOMWindow* callingWindow, LocalDOMWindo w* enteredWindow, SetLocation = SetLocation::Normal); | 93 void setLocation(const String&, LocalDOMWindow* callingWindow, LocalDOMWindo w* enteredWindow, SetLocation = SetLocation::Normal); |
| 87 | 94 |
| 88 const KURL& url() const; | 95 const KURL& url() const; |
| 96 | |
| 97 RawPtrWillBeWeakMember<Frame> m_frame; | |
| 89 }; | 98 }; |
| 90 | 99 |
| 91 } // namespace blink | 100 } // namespace blink |
| 92 | 101 |
| 93 #endif // Location_h | 102 #endif // Location_h |
| OLD | NEW |