123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #ifndef UPDATE_ENGINE_P2P_MANAGER_H_
- #define UPDATE_ENGINE_P2P_MANAGER_H_
- #include <string>
- #include <vector>
- #include <base/callback.h>
- #include <base/files/file_path.h>
- #include <base/memory/ref_counted.h>
- #include <base/time/time.h>
- #include <policy/device_policy.h>
- #include <policy/libpolicy.h>
- #include "update_engine/common/clock_interface.h"
- #include "update_engine/common/prefs_interface.h"
- #include "update_engine/update_manager/update_manager.h"
- namespace chromeos_update_engine {
- class P2PManager {
- public:
-
-
- class Configuration {
- public:
- virtual ~Configuration() {}
-
- virtual base::FilePath GetP2PDir() = 0;
-
-
-
- virtual std::vector<std::string> GetInitctlArgs(bool is_start) = 0;
-
-
- virtual std::vector<std::string> GetP2PClientArgs(
- const std::string& file_id, size_t minimum_size) = 0;
- };
- virtual ~P2PManager() {}
-
-
- typedef base::Callback<void(const std::string& url)> LookupCallback;
-
-
- virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy) = 0;
-
-
- virtual bool IsP2PEnabled() = 0;
-
-
-
- virtual bool EnsureP2PRunning() = 0;
-
-
-
- virtual bool EnsureP2PNotRunning() = 0;
-
-
-
-
- virtual bool PerformHousekeeping() = 0;
-
-
-
-
-
-
-
-
-
-
-
-
-
- virtual void LookupUrlForFile(const std::string& file_id,
- size_t minimum_size,
- base::TimeDelta max_time_to_wait,
- LookupCallback callback) = 0;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- virtual bool FileShare(const std::string& file_id, size_t expected_size) = 0;
-
-
-
-
- virtual base::FilePath FileGetPath(const std::string& file_id) = 0;
-
-
-
-
-
-
- virtual ssize_t FileGetSize(const std::string& file_id) = 0;
-
-
-
-
-
-
-
- virtual ssize_t FileGetExpectedSize(const std::string& file_id) = 0;
-
-
-
- virtual bool FileGetVisible(const std::string& file_id, bool* out_result) = 0;
-
-
-
-
- virtual bool FileMakeVisible(const std::string& file_id) = 0;
-
-
-
- virtual int CountSharedFiles() = 0;
-
-
-
-
-
-
-
-
-
-
-
-
- static P2PManager* Construct(
- Configuration* configuration,
- ClockInterface* clock,
- chromeos_update_manager::UpdateManager* update_manager,
- const std::string& file_extension,
- const int num_files_to_keep,
- const base::TimeDelta& max_file_age);
- };
- }
- #endif
|