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

Side by Side Diff: sql/mojo/mojo_vfs.cc

Issue 1225673006: Revert of mandoline filesystem: Save cookie data to the mojo:filesystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sqlite-fs
Patch Set: Created 5 years, 5 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
« no previous file with comments | « mojo/tools/mopy/gtest.py ('k') | sql/mojo/vfs_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "sql/mojo/mojo_vfs.h" 5 #include "sql/mojo/mojo_vfs.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/strings/stringprintf.h"
10 #include "components/filesystem/public/interfaces/file.mojom.h" 9 #include "components/filesystem/public/interfaces/file.mojom.h"
11 #include "components/filesystem/public/interfaces/file_system.mojom.h" 10 #include "components/filesystem/public/interfaces/file_system.mojom.h"
12 #include "components/filesystem/public/interfaces/types.mojom.h" 11 #include "components/filesystem/public/interfaces/types.mojom.h"
13 #include "mojo/public/cpp/bindings/lib/template_util.h" 12 #include "mojo/public/cpp/bindings/lib/template_util.h"
14 #include "mojo/util/capture_util.h" 13 #include "mojo/util/capture_util.h"
15 #include "third_party/sqlite/sqlite3.h" 14 #include "third_party/sqlite/sqlite3.h"
16 15
17 using mojo::Capture; 16 using mojo::Capture;
18 17
19 namespace sql { 18 namespace sql {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 open_flags = filesystem::kFlagOpenAlways; 238 open_flags = filesystem::kFlagOpenAlways;
240 } else { 239 } else {
241 open_flags = filesystem::kFlagOpen; 240 open_flags = filesystem::kFlagOpen;
242 } 241 }
243 open_flags |= filesystem::kFlagRead; 242 open_flags |= filesystem::kFlagRead;
244 if (flags & SQLITE_OPEN_READWRITE) 243 if (flags & SQLITE_OPEN_READWRITE)
245 open_flags |= filesystem::kFlagWrite; 244 open_flags |= filesystem::kFlagWrite;
246 if (flags & SQLITE_OPEN_DELETEONCLOSE) 245 if (flags & SQLITE_OPEN_DELETEONCLOSE)
247 open_flags |= filesystem::kDeleteOnClose; 246 open_flags |= filesystem::kDeleteOnClose;
248 247
249 mojo::String mojo_name;
250 if (name) {
251 // Don't let callers open the pattern of our temporary databases. When we
252 // open with a null name and SQLITE_OPEN_DELETEONCLOSE, we unlink the
253 // database after we open it. If we create a database here, close it
254 // normally, and then open the same file through the other path, we could
255 // delete the database.
256 CHECK(strncmp("Temp_", name, 5) != 0);
257 mojo_name = name;
258 } else {
259 DCHECK(flags & SQLITE_OPEN_DELETEONCLOSE);
260 static int temp_number = 0;
261 mojo_name = base::StringPrintf("Temp_%d.db", temp_number++);
262 }
263
264 // Grab the incoming file 248 // Grab the incoming file
265 filesystem::FilePtr file_ptr; 249 filesystem::FilePtr file_ptr;
266 filesystem::FileError error = filesystem::FILE_ERROR_FAILED; 250 filesystem::FileError error = filesystem::FILE_ERROR_FAILED;
267 GetRootDirectory(mojo_vfs)->OpenFile(mojo_name, GetProxy(&file_ptr), 251 GetRootDirectory(mojo_vfs)->OpenFile(mojo::String(name), GetProxy(&file_ptr),
268 open_flags, Capture(&error)); 252 open_flags, Capture(&error));
269 GetRootDirectory(mojo_vfs).WaitForIncomingResponse(); 253 GetRootDirectory(mojo_vfs).WaitForIncomingResponse();
270 if (error != filesystem::FILE_ERROR_OK) { 254 if (error != filesystem::FILE_ERROR_OK) {
271 // TODO(erg): Translate more of the mojo error codes into sqlite error 255 // TODO(erg): Translate more of the mojo error codes into sqlite error
272 // codes. 256 // codes.
273 return SQLITE_CANTOPEN; 257 return SQLITE_CANTOPEN;
274 } 258 }
275 259
276 // Set the method table so we can be closed (and run the manual dtor call to 260 // Set the method table so we can be closed (and run the manual dtor call to
277 // match the following placement news). 261 // match the following placement news).
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 404
421 CHECK(sqlite3_vfs_register(parent_, 1) == SQLITE_OK); 405 CHECK(sqlite3_vfs_register(parent_, 1) == SQLITE_OK);
422 CHECK(sqlite3_vfs_unregister(&mojo_vfs) == SQLITE_OK); 406 CHECK(sqlite3_vfs_unregister(&mojo_vfs) == SQLITE_OK);
423 } 407 }
424 408
425 filesystem::DirectoryPtr& ScopedMojoFilesystemVFS::GetDirectory() { 409 filesystem::DirectoryPtr& ScopedMojoFilesystemVFS::GetDirectory() {
426 return root_directory_; 410 return root_directory_;
427 } 411 }
428 412
429 } // namespace sql 413 } // namespace sql
OLDNEW
« no previous file with comments | « mojo/tools/mopy/gtest.py ('k') | sql/mojo/vfs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698