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

Side by Side Diff: third_party/WebKit/public/platform/WebPassOwnPtr.h

Issue 1447893002: compositor-worker: Introduce WebCompositorMutableState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback. Created 4 years, 11 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef WebPassOwnPtr_h 5 #ifndef WebPassOwnPtr_h
6 #define WebPassOwnPtr_h 6 #define WebPassOwnPtr_h
7 7
8 #include "public/platform/WebCommon.h" 8 #include "public/platform/WebCommon.h"
9 #include <cstddef> 9 #include <cstddef>
10 10
11 #if INSIDE_BLINK 11 #if INSIDE_BLINK
12 #include "wtf/PassOwnPtr.h" 12 #include "wtf/PassOwnPtr.h"
13 #else
14 #include <base/memory/scoped_ptr.h>
13 #endif 15 #endif
14 16
15 namespace blink { 17 namespace blink {
16 18
17 // WebPassOwnPtr<T> is used to pass a T pointer with ownership from chromium 19 // WebPassOwnPtr<T> is used to pass a T pointer with ownership from chromium
18 // side to blink side. T's definition must be shared among all users 20 // side to blink side. T's definition must be shared among all users
19 // (especially between chromium and blink). 21 // (especially between chromium and blink).
20 // TODO(yhirano): Migrate to scoped_ptr or std::unique_ptr once the repository 22 // TODO(yhirano): Migrate to scoped_ptr or std::unique_ptr once the repository
21 // merge is done or C++11 std library is allowed. 23 // merge is done or C++11 std library is allowed.
22 template <typename T> 24 template <typename T>
(...skipping 20 matching lines...) Expand all
43 } 45 }
44 WebPassOwnPtr& operator =(const WebPassOwnPtr&) = delete; 46 WebPassOwnPtr& operator =(const WebPassOwnPtr&) = delete;
45 47
46 #if INSIDE_BLINK 48 #if INSIDE_BLINK
47 PassOwnPtr<T> release() 49 PassOwnPtr<T> release()
48 { 50 {
49 T* ptr = m_ptr; 51 T* ptr = m_ptr;
50 m_ptr = nullptr; 52 m_ptr = nullptr;
51 return adoptPtr(ptr); 53 return adoptPtr(ptr);
52 } 54 }
55 #else
56 operator scoped_ptr<T>()
57 {
58 T* ptr = m_ptr;
59 m_ptr = nullptr;
60 return scoped_ptr<T>(ptr);
61 }
53 #endif // INSIDE_BLINK 62 #endif // INSIDE_BLINK
54 63
55 template <typename U> friend class WebPassOwnPtr; 64 template <typename U> friend class WebPassOwnPtr;
56 template <typename U> friend WebPassOwnPtr<U> adoptWebPtr(U*); 65 template <typename U> friend WebPassOwnPtr<U> adoptWebPtr(U*);
57 66
58 private: 67 private:
59 explicit WebPassOwnPtr(T* ptr) : m_ptr(ptr) {} 68 explicit WebPassOwnPtr(T* ptr) : m_ptr(ptr) {}
60 69
61 // See the constructor comment to see why |mutable| is needed. 70 // See the constructor comment to see why |mutable| is needed.
62 mutable T* m_ptr; 71 mutable T* m_ptr;
63 }; 72 };
64 73
65 template <typename T> 74 template <typename T>
66 WebPassOwnPtr<T> adoptWebPtr(T* p) { return WebPassOwnPtr<T>(p); } 75 WebPassOwnPtr<T> adoptWebPtr(T* p) { return WebPassOwnPtr<T>(p); }
67 76
68 } // namespace blink 77 } // namespace blink
69 78
70 #endif 79 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/public/platform/WebCompositorMutableStateProvider.h ('k') | ui/gfx/transform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698