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

Side by Side Diff: Source/WebCore/platform/mac/FileSystemMac.mm

Issue 13713003: Remove all of WebCore/platform/mac which is not mentioned in WebCore.gypi. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added back a couple needed headers Created 7 years, 8 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) 2007, 2011 Apple 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
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #import "config.h"
30 #import "FileSystem.h"
31
32 #import "WebCoreNSURLExtras.h"
33 #import "WebCoreSystemInterface.h"
34 #import <wtf/RetainPtr.h>
35 #import <wtf/text/CString.h>
36 #import <wtf/text/WTFString.h>
37
38 namespace WebCore {
39
40 String homeDirectoryPath()
41 {
42 return NSHomeDirectory();
43 }
44
45 String openTemporaryFile(const String& prefix, PlatformFileHandle& platformFileH andle)
46 {
47 platformFileHandle = invalidPlatformFileHandle;
48
49 Vector<char> temporaryFilePath(PATH_MAX);
50 if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryFilePath.data(), temporaryFi lePath.size()))
51 return String();
52
53 // Shrink the vector.
54 temporaryFilePath.shrink(strlen(temporaryFilePath.data()));
55 ASSERT(temporaryFilePath.last() == '/');
56
57 // Append the file name.
58 CString prefixUtf8 = prefix.utf8();
59 temporaryFilePath.append(prefixUtf8.data(), prefixUtf8.length());
60 temporaryFilePath.append("XXXXXX", 6);
61 temporaryFilePath.append('\0');
62
63 platformFileHandle = mkstemp(temporaryFilePath.data());
64 if (platformFileHandle == invalidPlatformFileHandle)
65 return String();
66
67 return String::fromUTF8(temporaryFilePath.data());
68 }
69
70 typedef struct MetaDataInfo
71 {
72 String URLString;
73 String referrer;
74 String path;
75 } MetaDataInfo;
76
77 static void* setMetaData(void* context)
78 {
79 MetaDataInfo *info = (MetaDataInfo *)context;
80 wkSetMetadataURL((NSString *)info->URLString, (NSString *)info->referrer, (N SString *)String(fileSystemRepresentation(info->path).data()));
81
82 delete info;
83
84 return 0;
85 }
86
87 void setMetadataURL(String& URLString, const String& referrer, const String& pat h)
88 {
89 NSURL *URL = URLWithUserTypedString(URLString, nil);
90 if (URL)
91 URLString = userVisibleString(URLByRemovingUserInfo(URL));
92
93 // Spawn a background thread for WKSetMetadataURL because this function will not return until mds has
94 // journaled the data we're're trying to set. Depending on what other I/O is going on, it can take some
95 // time.
96 pthread_t tid;
97 pthread_attr_t attr;
98 pthread_attr_init(&attr);
99 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
100
101 MetaDataInfo *info = new MetaDataInfo;
102
103 info->URLString = URLString;
104 info->referrer = referrer;
105 info->path = path;
106
107 pthread_create(&tid, &attr, setMetaData, info);
108 pthread_attr_destroy(&attr);
109 }
110
111 #if !PLATFORM(IOS)
112 bool canExcludeFromBackup()
113 {
114 return true;
115 }
116
117 bool excludeFromBackup(const String& path)
118 {
119 // It is critical to pass FALSE for excludeByPath because excluding by path requires root privileges.
120 CSBackupSetItemExcluded(pathAsURL(path).get(), TRUE, FALSE);
121 return true;
122 }
123 #endif
124
125 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/platform/mac/EventLoopMac.mm ('k') | Source/WebCore/platform/mac/HTMLConverter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698