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

Side by Side Diff: mojo/nacl/nonsfi/irt_pnacl_translator_compile.cc

Issue 1429953003: Belated code review regarding pexe content handler. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « no previous file | services/nacl/content_handler_main.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 <fcntl.h> 5 #include <fcntl.h>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h" 9 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h"
10 #include "mojo/public/cpp/bindings/string.h" 10 #include "mojo/public/cpp/bindings/string.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Read the pexe using fread, and write the pexe into the callback function. 49 // Read the pexe using fread, and write the pexe into the callback function.
50 static const size_t kBufferSize = 0x100000; 50 static const size_t kBufferSize = 0x100000;
51 scoped_ptr<char[]> buf(new char[kBufferSize]); 51 scoped_ptr<char[]> buf(new char[kBufferSize]);
52 FILE* pexe_file_stream = fopen(pexe_file_name.get().c_str(), "r"); 52 FILE* pexe_file_stream = fopen(pexe_file_name.get().c_str(), "r");
53 // Once the pexe has been opened, it is no longer needed, so we unlink it. 53 // Once the pexe has been opened, it is no longer needed, so we unlink it.
54 if (unlink(pexe_file_name.get().c_str())) 54 if (unlink(pexe_file_name.get().c_str()))
55 LOG(FATAL) << "Could not unlink temporary pexe file"; 55 LOG(FATAL) << "Could not unlink temporary pexe file";
56 if (pexe_file_stream == nullptr) 56 if (pexe_file_stream == nullptr)
57 LOG(FATAL) << "Could not open pexe for reading"; 57 LOG(FATAL) << "Could not open pexe for reading";
58 // TODO(smklein): Remove these LOG statements once translation speed
59 // is improved.
60 LOG(INFO) << "Starting compilation of pexe into nexe";
58 for (;;) { 61 for (;;) {
59 size_t num_bytes_from_pexe = fread(buf.get(), 1, kBufferSize, 62 size_t num_bytes_from_pexe = fread(buf.get(), 1, kBufferSize,
60 pexe_file_stream); 63 pexe_file_stream);
61 if (ferror(pexe_file_stream)) { 64 if (ferror(pexe_file_stream)) {
62 LOG(FATAL) << "Error reading from pexe file stream"; 65 LOG(FATAL) << "Error reading from pexe file stream";
63 } 66 }
64 if (num_bytes_from_pexe == 0) { 67 if (num_bytes_from_pexe == 0) {
65 break; 68 break;
66 } 69 }
67 funcs_->data_callback(buf.get(), num_bytes_from_pexe); 70 funcs_->data_callback(buf.get(), num_bytes_from_pexe);
71 LOG(INFO) << "Compiled " << num_bytes_from_pexe << " bytes";
68 } 72 }
69 buf.reset(); 73 buf.reset();
70 74
71 if (fclose(pexe_file_stream)) 75 if (fclose(pexe_file_stream))
72 LOG(FATAL) << "Failed to close pexe file stream from compiler nexe"; 76 LOG(FATAL) << "Failed to close pexe file stream from compiler nexe";
73 funcs_->end_callback(); 77 funcs_->end_callback();
74 78
75 // Return the name of the object file. 79 // Return the name of the object file.
76 callback.Run(mojo::String(obj_file_name.value())); 80 callback.Run(mojo::String(obj_file_name.value()));
77 mojo::RunLoop::current()->Quit(); 81 mojo::RunLoop::current()->Quit();
(...skipping 20 matching lines...) Expand all
98 } // namespace anonymous 102 } // namespace anonymous
99 103
100 namespace nacl { 104 namespace nacl {
101 105
102 const struct nacl_irt_private_pnacl_translator_compile 106 const struct nacl_irt_private_pnacl_translator_compile
103 nacl_irt_private_pnacl_translator_compile = { 107 nacl_irt_private_pnacl_translator_compile = {
104 ServeTranslateRequest 108 ServeTranslateRequest
105 }; 109 };
106 110
107 } // namespace nacl 111 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | services/nacl/content_handler_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698