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

Side by Side Diff: components/translate/content/browser/data_file_browser_cld_data_provider.cc

Issue 424053002: Add a new "Configure" mechanism to CLD browser-side data interfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sorin@'s comments Created 6 years, 4 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
OLDNEW
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
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 void DataFileBrowserCldDataProvider::SetCldDataFilePath( 47 void SetCldDataFilePath(const base::FilePath& path) {
48 const base::FilePath& path) {
49 VLOG(1) << "Setting CLD data file path to: " << path.value(); 48 VLOG(1) << "Setting CLD data file path to: " << path.value();
50 base::AutoLock lock(g_file_lock_.Get()); 49 base::AutoLock lock(g_file_lock_.Get());
51 if (g_cached_filepath == path) 50 if (g_cached_filepath == path)
52 return; // no change necessary 51 return; // no change necessary
53 g_cached_filepath = path; 52 g_cached_filepath = path;
54 // For sanity, clean these other values up just in case. 53 // For sanity, clean these other values up just in case.
55 g_cached_file = NULL; 54 g_cached_file = NULL;
56 g_cached_data_length = -1; 55 g_cached_data_length = -1;
57 g_cached_data_offset = -1; 56 g_cached_data_offset = -1;
58 } 57 }
59 58
60 base::FilePath DataFileBrowserCldDataProvider::GetCldDataFilePath() { 59 base::FilePath GetCldDataFilePath() {
61 base::AutoLock lock(g_file_lock_.Get()); 60 base::AutoLock lock(g_file_lock_.Get());
62 return g_cached_filepath; 61 return g_cached_filepath;
63 } 62 }
64 63
65 DataFileBrowserCldDataProvider::DataFileBrowserCldDataProvider( 64 DataFileBrowserCldDataProvider::DataFileBrowserCldDataProvider(
66 content::WebContents* web_contents) 65 content::WebContents* web_contents)
67 : web_contents_(web_contents), weak_pointer_factory_() { 66 : web_contents_(web_contents), weak_pointer_factory_() {
68 } 67 }
69 68
70 DataFileBrowserCldDataProvider::~DataFileBrowserCldDataProvider() { 69 DataFileBrowserCldDataProvider::~DataFileBrowserCldDataProvider() {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // Else, this request has taken care of it all. Cache all info. 234 // Else, this request has taken care of it all. Cache all info.
236 VLOG(1) << "Caching CLD data file information."; 235 VLOG(1) << "Caching CLD data file information.";
237 g_cached_file = file.release(); 236 g_cached_file = file.release();
238 g_cached_data_offset = data_offset; 237 g_cached_data_offset = data_offset;
239 g_cached_data_length = data_length; 238 g_cached_data_length = data_length;
240 } 239 }
241 } 240 }
242 } 241 }
243 242
244 } // namespace translate 243 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698