chore: DirectoryLister memory management improvement (#18634)
* chore: small memory management improvement Co-authored-by: Charles Kerr <ckerr@github.com> * chore: fix code style * use start-from-one ref count, check ref_counted.h for motivations * reuse list_base_dir_ * net::DirectorLister offloads directory enumeration to a different task sequence in its implementation, use of sequence runner on our end is unnecessary * Don't manually `Release` in `WebContentsDestroyed`, content::FileSelectListener already handles this case.
This commit is contained in:
parent
3859244a79
commit
3038846f5d
2 changed files with 47 additions and 77 deletions
|
@ -9,7 +9,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "net/base/directory_lister.h"
|
||||
#include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h"
|
||||
|
||||
namespace base {
|
||||
|
@ -24,32 +23,6 @@ class WebContents;
|
|||
|
||||
namespace electron {
|
||||
|
||||
class DirectoryListerHelperDelegate {
|
||||
public:
|
||||
virtual void OnDirectoryListerDone(
|
||||
std::vector<blink::mojom::FileChooserFileInfoPtr> file_info,
|
||||
base::FilePath base_dir) = 0;
|
||||
};
|
||||
|
||||
class DirectoryListerHelper
|
||||
: public net::DirectoryLister::DirectoryListerDelegate {
|
||||
public:
|
||||
DirectoryListerHelper(base::FilePath base,
|
||||
DirectoryListerHelperDelegate* helper);
|
||||
~DirectoryListerHelper() override;
|
||||
|
||||
private:
|
||||
void OnListFile(
|
||||
const net::DirectoryLister::DirectoryListerData& data) override;
|
||||
void OnListDone(int error) override;
|
||||
|
||||
base::FilePath base_dir_;
|
||||
DirectoryListerHelperDelegate* delegate_;
|
||||
std::vector<base::FilePath> paths_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DirectoryListerHelper);
|
||||
};
|
||||
|
||||
class NativeWindow;
|
||||
|
||||
class WebDialogHelper {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue