New issue
Advanced search Search tips

Issue 729442 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Sep 10
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug

Blocking:
issue 841659
issue 875700



Sign in to add a comment

Replace (bool, const std::string&) in filesystem_api_util.cc with base::Optional<std::string>

Project Member Reported by hashimoto@chromium.org, Jun 5 2017

Issue description

In https://codereview.chromium.org/2914433002/, dcheng@ suggested replacing (bool, const std::string&) with base::Optional<std::string> so that we can avoid constructing an empty std::string.
 
Cc: hidehiko@chromium.org
Also, hidehiko@ suggested to dedupe content::BrowserThread::PostTask(content::BrowserThread::UI, ...);

https://codereview.chromium.org/2914433002/diff/120001/chrome/browser/chromeos/file_manager/filesystem_api_util.cc#newcode159
As this function gets bigger, and it looks to have a dup code, how about small
refactoring, like;

namespace {

bool GetNonNativeLocalPathMimeTypeInteranl(...) {
  if (IsUnderDriveMountPoint(...)) {
    auto* file_system = GetFileSystemByProfile(profile);
    if (!file_system)
      return false;
    ...
    return true;
  }

  if (IsFileSystemProviderLocalPath(...)) {
    ... parser ...
    if (!parser.Parse())
      return false;
    ...
    return true;
  }

  ... ditto  for your new code ...
  return false;
}

}  // namespace

void GetNonNativeLocalPathMimeType(...) {
  if (GetNonNativeLocalPathMimeType(...)) {
    // callback is deferred to the async operation, so do nothing.
    return;
  }
  // PostTask once to be consistent with async operation.
  PostTask(UI, FROM_HERE, BindOnce(callback, false, std::string()));
}
Components: Platform>Apps>FileManager

Comment 3 by sashab@chromium.org, Feb 24 2018

Labels: CrOS-FilesApp-CodeHealth

Comment 4 by sashab@chromium.org, Feb 28 2018

Labels: -CrOS-FilesApp-CodeHealth CrOSFilesCategory-CodeHealth
Cc: hashimoto@chromium.org
Owner: ----
Status: Available (was: Assigned)
Blocking: 875700 841659
Owner: slangley@chromium.org
Status: Started (was: Available)
Status: Fixed (was: Started)
Project Member

Comment 8 by bugdroid1@chromium.org, Sep 10

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d37ba940a61158d97cc6886bb7a84f0e01b0635b

commit d37ba940a61158d97cc6886bb7a84f0e01b0635b
Author: Stuart Langley <slangley@google.com>
Date: Mon Sep 10 07:05:06 2018

Replace (bool, const std::string&) with base::Optional<std::string>

As per the attached bug, replace usage of Replace (bool, const std::string&) in
filesystem_api_util.cc with base::Optional<std::string> for code health.

Also, change from RepeatingCallback to OnceCallback for all filesystem_api_util
defined methods.

Also, fix linter warnings.

There are no logic changes.

Bug:  729442 , 875700
Change-Id: Ib27634b9ba1372cb007ba6a190608ec4128bbeb3
Reviewed-on: https://chromium-review.googlesource.com/1215425
Reviewed-by: Sam McNally <sammc@chromium.org>
Reviewed-by: Noel Gordon <noel@chromium.org>
Commit-Queue: Stuart Langley <slangley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589842}
[modify] https://crrev.com/d37ba940a61158d97cc6886bb7a84f0e01b0635b/chrome/browser/chromeos/file_manager/filesystem_api_util.cc
[modify] https://crrev.com/d37ba940a61158d97cc6886bb7a84f0e01b0635b/chrome/browser/chromeos/file_manager/filesystem_api_util.h
[modify] https://crrev.com/d37ba940a61158d97cc6886bb7a84f0e01b0635b/chrome/browser/extensions/api/file_handlers/non_native_file_system_delegate_chromeos.cc
[modify] https://crrev.com/d37ba940a61158d97cc6886bb7a84f0e01b0635b/chrome/browser/extensions/api/file_handlers/non_native_file_system_delegate_chromeos.h
[modify] https://crrev.com/d37ba940a61158d97cc6886bb7a84f0e01b0635b/extensions/browser/api/file_handlers/mime_util.cc
[modify] https://crrev.com/d37ba940a61158d97cc6886bb7a84f0e01b0635b/extensions/browser/api/file_handlers/non_native_file_system_delegate.h

Sign in to add a comment