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

Unified Diff: mojo/file_utils/file_util.cc

Issue 1923573002: Convert //mojo/file_utils to use SynchronousInterfacePtr. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/file_utils/file_util.h ('k') | mojo/file_utils/file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/file_utils/file_util.cc
diff --git a/mojo/file_utils/file_util.cc b/mojo/file_utils/file_util.cc
index 28d7f1db4ee159528d8b0bd4b4d0f85cdf7478a2..18fa83bc31fd9cf9bf25b60dca0c44edc6567e26 100644
--- a/mojo/file_utils/file_util.cc
+++ b/mojo/file_utils/file_util.cc
@@ -6,20 +6,18 @@
#include <stdint.h>
-#include "mojo/services/files/interfaces/directory.mojom.h"
-#include "mojo/services/files/interfaces/file.mojom.h"
#include "mojo/services/files/interfaces/types.mojom.h"
namespace file_utils {
-mojo::files::FilePtr CreateTemporaryFileInDir(
- mojo::files::DirectoryPtr* directory,
+mojo::InterfaceHandle<mojo::files::File> CreateTemporaryFileInDir(
+ mojo::SynchronousInterfacePtr<mojo::files::Directory>* directory,
std::string* path_name) {
std::string internal_path_name;
const std::string charset("abcdefghijklmnopqrstuvwxyz1234567890");
const unsigned kSuffixLength = 6;
const unsigned kMaxNumAttempts = 10;
- mojo::files::FilePtr temp_file;
+ mojo::InterfaceHandle<mojo::files::File> temp_file;
mojo::files::Error error = mojo::files::Error::INTERNAL;
uint64_t random_value = 0;
for (unsigned attempt = 0; attempt < kMaxNumAttempts; attempt++) {
@@ -31,13 +29,13 @@ mojo::files::FilePtr CreateTemporaryFileInDir(
random_value += (microseconds << 16) ^ (microseconds / 1000000);
internal_path_name.push_back(charset[random_value % charset.length()]);
}
- (*directory)
- ->OpenFile(internal_path_name, GetProxy(&temp_file),
- mojo::files::kOpenFlagWrite | mojo::files::kOpenFlagRead |
- mojo::files::kOpenFlagCreate |
- mojo::files::kOpenFlagExclusive,
- [&error](mojo::files::Error e) { error = e; });
- if (!directory->WaitForIncomingResponse())
+ if (!(*directory)
+ ->OpenFile(internal_path_name, GetProxy(&temp_file),
+ mojo::files::kOpenFlagWrite |
+ mojo::files::kOpenFlagRead |
+ mojo::files::kOpenFlagCreate |
+ mojo::files::kOpenFlagExclusive,
+ &error))
return nullptr;
// TODO(smklein): React to error code when ErrnoToError can return something
// other than Error::UNKNOWN. We only want to retry when "EEXIST" is thrown.
« no previous file with comments | « mojo/file_utils/file_util.h ('k') | mojo/file_utils/file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698