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

Side by Side Diff: public/web/WebMIDIPermissionRequest.h

Issue 311773003: Decouple MIDIAccess initialization from MIDIAccess class. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef WebMIDIPermissionRequest_h 31 #ifndef WebMIDIPermissionRequest_h
32 #define WebMIDIPermissionRequest_h 32 #define WebMIDIPermissionRequest_h
33 33
34 #include "../platform/WebCommon.h" 34 #include "../platform/WebCommon.h"
35 #include "../platform/WebPrivatePtr.h"
36 35
37 namespace WebCore { 36 namespace WebCore {
38 class MIDIAccess; 37 class MIDIAccessInitializer;
39 } 38 }
40 39
41 namespace blink { 40 namespace blink {
42 41
43 class WebSecurityOrigin; 42 class WebSecurityOrigin;
44 43
45 // WebMIDIPermissionRequest encapsulates a WebCore MIDIAccess object and represe nts 44 // WebMIDIPermissionRequest encapsulates a WebCore MIDIAccessInitializer
46 // a request from WebCore for permissions. 45 // object and represents a request from WebCore for permissions.
47 // The underlying MIDIAccess object is guaranteed to be valid until the invocati on of 46 // The underlying object is guaranteed to be valid until the invocation of
48 // either WebMIDIPermissionRequest::setIsAllowed (request complete) or 47 // either WebMIDIPermissionRequest::setIsAllowed (request complete) or
49 // WebMIDIClient::cancelPermissionRequest (request canceled). 48 // WebMIDIClient::cancelPermissionRequest (request canceled).
50 class WebMIDIPermissionRequest { 49 class WebMIDIPermissionRequest {
51 public: 50 public:
52 WebMIDIPermissionRequest(const WebMIDIPermissionRequest& o) { assign(o); } 51 BLINK_EXPORT WebMIDIPermissionRequest(const WebMIDIPermissionRequest& other)
53 ~WebMIDIPermissionRequest() { reset(); }; 52 : m_initializer(other.m_initializer) { }
54
55 BLINK_EXPORT WebSecurityOrigin securityOrigin() const; 53 BLINK_EXPORT WebSecurityOrigin securityOrigin() const;
56 BLINK_EXPORT void setIsAllowed(bool); 54 BLINK_EXPORT void setIsAllowed(bool);
57 55
58 BLINK_EXPORT void reset();
59 BLINK_EXPORT void assign(const WebMIDIPermissionRequest&);
60 BLINK_EXPORT bool equals(const WebMIDIPermissionRequest&) const; 56 BLINK_EXPORT bool equals(const WebMIDIPermissionRequest&) const;
61 57
62 #if BLINK_IMPLEMENTATION 58 #if BLINK_IMPLEMENTATION
63 explicit WebMIDIPermissionRequest(const PassRefPtrWillBeRawPtr<WebCore::MIDI Access>&); 59 explicit WebMIDIPermissionRequest(WebCore::MIDIAccessInitializer*);
64 60
65 WebCore::MIDIAccess* midiAccess() const { return m_private.get(); } 61 WebCore::MIDIAccessInitializer* midiAccessInitializer() const { return m_ini tializer; }
66 #endif 62 #endif
67 63
68 private: 64 private:
69 WebPrivatePtr<WebCore::MIDIAccess> m_private; 65 WebCore::MIDIAccessInitializer* m_initializer;
Takashi Toyoshima 2014/06/04 22:03:53 Can we ensure that m_initializer continues to be v
yhirano 2014/06/05 11:35:25 I updated the class comment: is it clear now?
tkent 2014/06/10 04:28:31 I don't understand how it is ensured. This looks v
70 }; 66 };
71 67
72 inline bool operator==(const WebMIDIPermissionRequest& a, const WebMIDIPermissio nRequest& b) 68 inline bool operator==(const WebMIDIPermissionRequest& a, const WebMIDIPermissio nRequest& b)
73 { 69 {
74 return a.equals(b); 70 return a.equals(b);
75 } 71 }
76 72
77 inline bool operator!=(const WebMIDIPermissionRequest& a, const WebMIDIPermissio nRequest& b) 73 inline bool operator!=(const WebMIDIPermissionRequest& a, const WebMIDIPermissio nRequest& b)
78 { 74 {
79 return !(a == b); 75 return !(a == b);
80 } 76 }
81 77
82 } // namespace blink 78 } // namespace blink
83 79
84 #endif // WebMIDIPermissionRequest_h 80 #endif // WebMIDIPermissionRequest_h
OLDNEW
« Source/modules/webmidi/MIDIClient.h ('K') | « Source/web/WebMIDIPermissionRequest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698