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

Side by Side Diff: gin/modules/file_module_provider.cc

Issue 401723002: Mojo: Log an error when we fail to find a JS module. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: way simpler Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "gin/modules/file_module_provider.h" 5 #include "gin/modules/file_module_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 22 matching lines...) Expand all
33 33
34 for (size_t i = 0; i < search_paths.size(); ++i) { 34 for (size_t i = 0; i < search_paths.size(); ++i) {
35 std::string source; 35 std::string source;
36 if (!ReadFileToString(search_paths[i].Append(path), &source)) 36 if (!ReadFileToString(search_paths[i].Append(path), &source))
37 continue; 37 continue;
38 38
39 Runner::Scope scope(runner.get()); 39 Runner::Scope scope(runner.get());
40 runner->Run(source, id); 40 runner->Run(source, id);
41 return; 41 return;
42 } 42 }
43 LOG(ERROR) << "Failed to load module from disk: " << id;
43 } 44 }
44 45
45 } // namespace 46 } // namespace
46 47
47 FileModuleProvider::FileModuleProvider( 48 FileModuleProvider::FileModuleProvider(
48 const std::vector<base::FilePath>& search_paths) 49 const std::vector<base::FilePath>& search_paths)
49 : search_paths_(search_paths) { 50 : search_paths_(search_paths) {
50 } 51 }
51 52
52 FileModuleProvider::~FileModuleProvider() { 53 FileModuleProvider::~FileModuleProvider() {
53 } 54 }
54 55
55 void FileModuleProvider::AttempToLoadModules( 56 void FileModuleProvider::AttempToLoadModules(
56 Runner* runner, const std::set<std::string>& ids) { 57 Runner* runner, const std::set<std::string>& ids) {
57 std::set<std::string> modules = ids; 58 std::set<std::string> modules = ids;
58 for (std::set<std::string>::const_iterator it = modules.begin(); 59 for (std::set<std::string>::const_iterator it = modules.begin();
59 it != modules.end(); ++it) { 60 it != modules.end(); ++it) {
60 const std::string& id = *it; 61 const std::string& id = *it;
61 if (attempted_ids_.count(id)) 62 if (attempted_ids_.count(id))
62 continue; 63 continue;
63 attempted_ids_.insert(id); 64 attempted_ids_.insert(id);
64 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( 65 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(
65 AttempToLoadModule, runner->GetWeakPtr(), search_paths_, id)); 66 AttempToLoadModule, runner->GetWeakPtr(), search_paths_, id));
66 } 67 }
67 } 68 }
68 69
69 } // namespace gin 70 } // namespace gin
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698