rlz_lib_clear.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "rlz/lib/rlz_lib_clear.h"
  5. #include "rlz/lib/assert.h"
  6. #include "rlz/lib/rlz_value_store.h"
  7. namespace rlz_lib {
  8. bool ClearAllProductEvents(Product product) {
  9. ScopedRlzValueStoreLock lock;
  10. RlzValueStore* store = lock.GetStore();
  11. if (!store || !store->HasAccess(RlzValueStore::kWriteAccess))
  12. return false;
  13. bool result;
  14. result = store->ClearAllProductEvents(product);
  15. result &= store->ClearAllStatefulEvents(product);
  16. return result;
  17. }
  18. void ClearProductState(Product product, const AccessPoint* access_points) {
  19. ScopedRlzValueStoreLock lock;
  20. RlzValueStore* store = lock.GetStore();
  21. if (!store || !store->HasAccess(RlzValueStore::kWriteAccess))
  22. return;
  23. // Delete all product specific state.
  24. VERIFY(ClearAllProductEvents(product));
  25. VERIFY(store->ClearPingTime(product));
  26. // Delete all RLZ's for access points being uninstalled.
  27. if (access_points) {
  28. for (int i = 0; access_points[i] != NO_ACCESS_POINT; i++) {
  29. VERIFY(store->ClearAccessPointRlz(access_points[i]));
  30. }
  31. }
  32. store->CollectGarbage();
  33. }
  34. } // namespace rlz_lib