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

Side by Side Diff: third_party/WebKit/WebCore/dom/CrossThreadCopier.h

Issue 20076: WebKit merge 40500:40539 [WebKit side] (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 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
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 */
30
31 #ifndef CrossThreadCopier_h
32 #define CrossThreadCopier_h
33
34 #if ENABLE(WORKERS)
35
36 #include <memory>
37 #include <wtf/PassRefPtr.h>
38 #include <wtf/RefPtr.h>
39 #include <wtf/Threading.h>
40 #include <wtf/TypeTraits.h>
41
42 namespace WebCore {
43
44 class ResourceError;
45 class ResourceRequest;
46 class ResourceResponse;
47 class String;
48 struct CrossThreadResourceResponseData;
49 struct CrossThreadResourceRequestData;
50
51 template<typename T> struct CrossThreadCopierPassThrough {
52 typedef T Type;
53 static Type copy(const T& parameter)
54 {
55 return parameter;
56 }
57 };
58
59 template<bool isConvertibleToInteger, typename T> struct CrossThreadCopierBa se;
60
61 // Integers get passed through without any changes.
62 template<typename T> struct CrossThreadCopierBase<true, T> : public CrossThr eadCopierPassThrough<T> {
63 };
64
65 // Pointers get passed through without any significant changes.
66 template<typename T> struct CrossThreadCopierBase<false, T*> : public CrossT hreadCopierPassThrough<T*> {
67 };
68
69 // Custom copy methods.
70 template<typename T> struct CrossThreadCopierBase<false, RefPtr<ThreadSafeSh ared<T> > > {
71 typedef PassRefPtr<T> Type;
72 static Type copy(const RefPtr<ThreadSafeShared<T> >& refPtr)
73 {
74 return PassRefPtr<T>(static_cast<T*>(refPtr.get()));
75 }
76 };
77
78 template<typename T> struct CrossThreadCopierBase<false, std::auto_ptr<T> > {
79 typedef std::auto_ptr<T> Type;
80 static Type copy(const std::auto_ptr<T>& autoPtr)
81 {
82 return std::auto_ptr<T>(*const_cast<std::auto_ptr<T>*>(&autoPtr));
83 }
84 };
85
86 template<> struct CrossThreadCopierBase<false, String> {
87 typedef String Type;
88 static Type copy(const String&);
89 };
90
91 template<> struct CrossThreadCopierBase<false, ResourceError> {
92 typedef ResourceError Type;
93 static Type copy(const ResourceError&);
94 };
95
96 template<> struct CrossThreadCopierBase<false, ResourceRequest> {
97 typedef std::auto_ptr<CrossThreadResourceRequestData> Type;
98 static Type copy(const ResourceRequest&);
99 };
100
101 template<> struct CrossThreadCopierBase<false, ResourceResponse> {
102 typedef std::auto_ptr<CrossThreadResourceResponseData> Type;
103 static Type copy(const ResourceResponse&);
104 };
105
106 template<typename T> struct CrossThreadCopier : public CrossThreadCopierBase <WTF::IsConvertibleToInteger<T>::value, T> {
107 };
108
109 } // namespace WebCore
110
111 #endif // ENABLE(WORKERS)
112
113 #endif // CrossThreadCopier_h
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/css/CSSStyleSelector.cpp ('k') | third_party/WebKit/WebCore/dom/CrossThreadCopier.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698