Do not store resource_path as FilePath
On Windows the path value returned by PathWithoutParams also uses "/" as separator, so there is no need to use the FilePath class.
This commit is contained in:
parent
cca1db47ee
commit
422b7acece
1 changed files with 3 additions and 7 deletions
|
@ -33,10 +33,7 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
public:
|
public:
|
||||||
BundledDataSource() {
|
BundledDataSource() {
|
||||||
for (size_t i = 0; i < kPdfViewerResourcesSize; ++i) {
|
for (size_t i = 0; i < kPdfViewerResourcesSize; ++i) {
|
||||||
base::FilePath resource_path =
|
std::string resource_path = kPdfViewerResources[i].name;
|
||||||
base::FilePath().AppendASCII(kPdfViewerResources[i].name);
|
|
||||||
resource_path = resource_path.NormalizePathSeparators();
|
|
||||||
|
|
||||||
DCHECK(path_to_resource_id_.find(resource_path) ==
|
DCHECK(path_to_resource_id_.find(resource_path) ==
|
||||||
path_to_resource_id_.end());
|
path_to_resource_id_.end());
|
||||||
path_to_resource_id_[resource_path] = kPdfViewerResources[i].value;
|
path_to_resource_id_[resource_path] = kPdfViewerResources[i].value;
|
||||||
|
@ -51,8 +48,7 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
|
const content::ResourceRequestInfo::WebContentsGetter& wc_getter,
|
||||||
const GotDataCallback& callback) override {
|
const GotDataCallback& callback) override {
|
||||||
std::string filename = PathWithoutParams(path);
|
std::string filename = PathWithoutParams(path);
|
||||||
auto entry =
|
auto entry = path_to_resource_id_.find(filename);
|
||||||
path_to_resource_id_.find(base::FilePath::FromUTF8Unsafe(filename));
|
|
||||||
|
|
||||||
if (entry != path_to_resource_id_.end()) {
|
if (entry != path_to_resource_id_.end()) {
|
||||||
int resource_id = entry->second;
|
int resource_id = entry->second;
|
||||||
|
@ -82,7 +78,7 @@ class BundledDataSource : public content::URLDataSource {
|
||||||
~BundledDataSource() override {}
|
~BundledDataSource() override {}
|
||||||
|
|
||||||
// A map from a resource path to the resource ID.
|
// A map from a resource path to the resource ID.
|
||||||
std::map<base::FilePath, int> path_to_resource_id_;
|
std::map<std::string, int> path_to_resource_id_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|
DISALLOW_COPY_AND_ASSIGN(BundledDataSource);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue