OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "data_file_browser_cld_data_provider.h" | 5 #include "data_file_browser_cld_data_provider.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 namespace translate { | 37 namespace translate { |
38 | 38 |
39 // Implementation of the static factory method from BrowserCldDataProvider, | 39 // Implementation of the static factory method from BrowserCldDataProvider, |
40 // hooking up this specific implementation for all of Chromium. | 40 // hooking up this specific implementation for all of Chromium. |
41 BrowserCldDataProvider* CreateBrowserCldDataProviderFor( | 41 BrowserCldDataProvider* CreateBrowserCldDataProviderFor( |
42 content::WebContents* web_contents) { | 42 content::WebContents* web_contents) { |
43 VLOG(1) << "Creating DataFileBrowserCldDataProvider"; | 43 VLOG(1) << "Creating DataFileBrowserCldDataProvider"; |
44 return new DataFileBrowserCldDataProvider(web_contents); | 44 return new DataFileBrowserCldDataProvider(web_contents); |
45 } | 45 } |
46 | 46 |
| 47 // This implementation requires the parameter to be a pointer to an object |
| 48 // of type base::FilePath. A copy will be made and SetCldDataFilePath will |
| 49 // be invoked. This allows configuration by the browser for both the |
| 50 // "component" and "standalone" data sources without the need to explicitly |
| 51 // depend upon one or the other at compile time. |
| 52 void ConfigureBrowserCldDataProvider(const void* config) { |
| 53 const base::FilePath* as_path = static_cast<const base::FilePath*>(config); |
| 54 DataFileBrowserCldDataProvider::SetCldDataFilePath(*as_path); |
| 55 } |
| 56 |
47 void DataFileBrowserCldDataProvider::SetCldDataFilePath( | 57 void DataFileBrowserCldDataProvider::SetCldDataFilePath( |
48 const base::FilePath& path) { | 58 const base::FilePath& path) { |
49 VLOG(1) << "Setting CLD data file path to: " << path.value(); | 59 VLOG(1) << "Setting CLD data file path to: " << path.value(); |
50 base::AutoLock lock(g_file_lock_.Get()); | 60 base::AutoLock lock(g_file_lock_.Get()); |
51 if (g_cached_filepath == path) | 61 if (g_cached_filepath == path) |
52 return; // no change necessary | 62 return; // no change necessary |
53 g_cached_filepath = path; | 63 g_cached_filepath = path; |
54 // For sanity, clean these other values up just in case. | 64 // For sanity, clean these other values up just in case. |
55 g_cached_file = NULL; | 65 g_cached_file = NULL; |
56 g_cached_data_length = -1; | 66 g_cached_data_length = -1; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 // Else, this request has taken care of it all. Cache all info. | 245 // Else, this request has taken care of it all. Cache all info. |
236 VLOG(1) << "Caching CLD data file information."; | 246 VLOG(1) << "Caching CLD data file information."; |
237 g_cached_file = file.release(); | 247 g_cached_file = file.release(); |
238 g_cached_data_offset = data_offset; | 248 g_cached_data_offset = data_offset; |
239 g_cached_data_length = data_length; | 249 g_cached_data_length = data_length; |
240 } | 250 } |
241 } | 251 } |
242 } | 252 } |
243 | 253 |
244 } // namespace translate | 254 } // namespace translate |
OLD | NEW |