-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mediaview: Implement ArcDocumentsProviderWatcherManager.
ArcDocumentsProviderWatcherManager simply calls ArcDocumentsProviderRoot. BUG=chromium:684233 TEST=trybot TEST=Media view refreshes on media provider changes. Review-Url: https://codereview.chromium.org/2709013003 Cr-Commit-Position: refs/heads/master@{#454598} (cherry picked from commit 7b44260) Review-Url: https://codereview.chromium.org/2736613002 . Cr-Commit-Position: refs/branch-heads/3029@{#14} Cr-Branched-From: 939b32e-refs/heads/master@{#454471}
- Loading branch information
Showing
6 changed files
with
129 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.h" | ||
|
||
#include "base/files/file.h" | ||
#include "base/files/file_path.h" | ||
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h" | ||
#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root_map.h" | ||
#include "content/public/browser/browser_thread.h" | ||
#include "storage/browser/fileapi/file_system_url.h" | ||
|
||
using content::BrowserThread; | ||
using storage::FileSystemURL; | ||
|
||
namespace arc { | ||
|
||
ArcDocumentsProviderWatcherManager::ArcDocumentsProviderWatcherManager( | ||
ArcDocumentsProviderRootMap* roots) | ||
: roots_(roots), weak_ptr_factory_(this) {} | ||
|
||
ArcDocumentsProviderWatcherManager::~ArcDocumentsProviderWatcherManager() { | ||
DCHECK_CURRENTLY_ON(BrowserThread::IO); | ||
} | ||
|
||
void ArcDocumentsProviderWatcherManager::AddWatcher( | ||
const FileSystemURL& url, | ||
bool recursive, | ||
const StatusCallback& callback, | ||
const NotificationCallback& notification_callback) { | ||
DCHECK_CURRENTLY_ON(BrowserThread::IO); | ||
|
||
if (recursive) { | ||
// Recursive watching is not supported. | ||
callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | ||
return; | ||
} | ||
|
||
base::FilePath path; | ||
ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path); | ||
if (!root) { | ||
callback.Run(base::File::FILE_ERROR_NOT_FOUND); | ||
return; | ||
} | ||
|
||
root->AddWatcher(path, notification_callback, callback); | ||
} | ||
|
||
void ArcDocumentsProviderWatcherManager::RemoveWatcher( | ||
const FileSystemURL& url, | ||
bool recursive, | ||
const StatusCallback& callback) { | ||
DCHECK_CURRENTLY_ON(BrowserThread::IO); | ||
|
||
if (recursive) { | ||
// Recursive watching is not supported. | ||
callback.Run(base::File::FILE_ERROR_INVALID_OPERATION); | ||
return; | ||
} | ||
|
||
base::FilePath path; | ||
ArcDocumentsProviderRoot* root = roots_->ParseAndLookup(url, &path); | ||
if (!root) { | ||
callback.Run(base::File::FILE_ERROR_NOT_FOUND); | ||
return; | ||
} | ||
|
||
root->RemoveWatcher(path, callback); | ||
} | ||
|
||
} // namespace arc |
47 changes: 47 additions & 0 deletions
47
chrome/browser/chromeos/arc/fileapi/arc_documents_provider_watcher_manager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_WATCHER_MANAGER_H_ | ||
#define CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_WATCHER_MANAGER_H_ | ||
|
||
#include "base/macros.h" | ||
#include "base/memory/weak_ptr.h" | ||
#include "storage/browser/fileapi/watcher_manager.h" | ||
|
||
namespace arc { | ||
|
||
class ArcDocumentsProviderRootMap; | ||
|
||
// The implementation of storage::WatcherManager for ARC documents provider | ||
// filesystem. | ||
// | ||
// Note that this WatcherManager is not always correct. See comments at | ||
// ArcDocumentsProviderRoot::AddWatcher(). | ||
class ArcDocumentsProviderWatcherManager : public storage::WatcherManager { | ||
public: | ||
explicit ArcDocumentsProviderWatcherManager( | ||
ArcDocumentsProviderRootMap* roots); | ||
~ArcDocumentsProviderWatcherManager() override; | ||
|
||
// storage::WatcherManager overrides. | ||
void AddWatcher(const storage::FileSystemURL& url, | ||
bool recursive, | ||
const StatusCallback& callback, | ||
const NotificationCallback& notification_callback) override; | ||
void RemoveWatcher(const storage::FileSystemURL& url, | ||
bool recursive, | ||
const StatusCallback& callback) override; | ||
|
||
private: | ||
// Owned by ArcDocumentsProviderBackendDelegate. | ||
ArcDocumentsProviderRootMap* const roots_; | ||
|
||
base::WeakPtrFactory<ArcDocumentsProviderWatcherManager> weak_ptr_factory_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(ArcDocumentsProviderWatcherManager); | ||
}; | ||
|
||
} // namespace arc | ||
|
||
#endif // CHROME_BROWSER_CHROMEOS_ARC_FILEAPI_ARC_DOCUMENTS_PROVIDER_WATCHER_MANAGER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters