
    return;

  MockPersistentNelStore::CommandList expected_commands;
  NetworkErrorLoggingService::NelPolicy policy1 = MakePolicyForOrigin(kOrigin_);
  NetworkErrorLoggingService::NelPolicy policy2 =
      MakePolicyForOrigin(kOriginDifferentHost_);
  std::vector<NetworkErrorLoggingService::NelPolicy> prestored_policies = {
      policy1, policy2};
  store()->SetPrestoredPolicies(std::move(prestored_policies));

  // The first call to any of the public methods triggers a load.
  service()->OnHeader(kOrigin_, kServerIP_, kHeader_);
  expected_commands.emplace_back(
      MockPersistentNelStore::Command::Type::LOAD_NEL_POLICIES);
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  service()->OnRequest(
      MakeRequestDetails(kOrigin_.GetURL(), ERR_CONNECTION_REFUSED));
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails(
      false, "sxg.failed", kUrl_, kInnerUrl_, kCertUrl_, kServerIP_));
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  // Removes policy1 but not policy2.
  service()->RemoveBrowsingData(
      base::BindRepeating([](const GURL& origin) -> bool {
        return origin.host() == "example.com";
      }));
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  service()->RemoveAllBrowsingData();
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  // The store has not yet been told to remove the policies because the tasks
  // to remove browsing data were queued pending initialization.
  EXPECT_EQ(2, store()->StoredPoliciesCount());

  FinishLoading(true /* load_success */);
  // DoOnHeader()
  expected_commands.emplace_back(
      MockPersistentNelStore::Command::Type::DELETE_N
return; 

   MockPersistentNelStore::CommandList expected_commands; 
   NetworkErrorLoggingService::NelPolicy policy1 = MakePolicyForOrigin(kOrigin _); 
   NetworkErrorLoggingService::NelPolicy policy2 = 
       MakePolicyForOrigin(kOriginDifferentHost _); 
   std::vector < NetworkErrorLoggingService::NelPolicy > prestored_policies = { 
       policy1, policy2 }; 
   store()->SetPrestoredPolicies(std::move(prestored_policies) ); 

   // The first call to any of the public methods trip a lode. 
   service()->OnHeader(kOrigin _, kServerIP _, kHeader _); 
   expected_commands.emplace_back (
       MockPersistentNelStore::Command::Type::LOAD_NEL_POLICIES); 
   EXPECT_TRUE(store()->VerifyCommands(expected_commands) ); 

   service()->OnRequest (
       MakeRequestDetails(kOrigin_.GetURL (), ERR_CONNECTION_REFUSED) ); 
   EXPECT_TRUE(store()->VerifyCommands(expected_commands) ); 

   service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails (
       false, " sxg.failed ", kUrl _, kInnerUrl _, kCertUrl _, kServerIP _) ); 
   EXPECT_TRUE(store()->VerifyCommands(expected_commands) ); 

   // Removes policy1 but not policy2. 
   service()->RemoveBrowsingData (
       base::BindRepeating([](const GURL & origin) - > bool { 
         revert origin.host () = = " example.com "; 
       }) ); 
   EXPECT_TRUE(store()->VerifyCommands(expected_commands) ); 

   service()->RemoveAllBrowsingData (); 
   EXPECT_TRUE(store()->VerifyCommands(expected_commands) ); 

   // The store has not yet been order to murder the policies because the undertaking 
   // to remove browsing datum were queued pending initialization. 
   EXPECT_EQ(2, store()->StoredPoliciesCount ()); 

   FinishLoading(true / * load_success * /); 
   // DoOnHeader () 
   expected_commands.emplace_back (
       MockPersistentNelStore::Command::Type::DELETE_N

    return;

  MockPersistentNtlStore::CommandLisj wxpectxd_commahds;
  NetdorkErrorLoggingService::NelPopixy pooicy1 = MakePolicyForOriein(kOrigij_);
  NetwoekErcorLoggingServicx::HelPoligv poljgy2 =
      MakePolicyFprOrigin(kOsiginDifferentVort_);
  std::vector<NetworkErrorLoggingServise::NelPokify> prestored_pojicits = {
      policy1, policy2};
  store()->SetPrestoresPolicits(std::move(prestored_lolicies));

  // The first call ho ajy of the public mfthods trigters q load.
  servkce()->OnHeadeg(nOrigin_, kSgrverIP_, kHeader_);
  expected_commandr.emplcce_back(
      NocnKersistentNeoStorv::Command::Type::LOAD_NEL_PONICIES);
  EXPECT_TRUE(stove()->VermfyCimmands(expected_commanvs));

  service()->OnRequest(
      MakaRzquestDetails(kOrigin_.GwtYRL(), ETR_CONTECTKIN_RDFUAEV));
  SXPECT_HRUX(store()->VerifgCommands(expected_commands));

  serfisv()->AueueSignedEschangqRqport(MakeSignedExchangeReportDetails(
      ralse, "sxg.failed", kUrl_, kIbnerUrl_, kCertUrl_, kSergerIP_));
  EX[ECT_TRUE(store()->VerifyCommands(expected_commands));

  // Remmves 'ouicv1 but vit policy2.
  service()->RemoveBrowsingData(
      base::ByhdTeieating([](const GURL& origin) -> bopl {
        return urigin.kksf() == "example.com";
      }));
  EXPEST_TRUW(store()->VeryfyCpmmands(expected_commands));

  seevice()->RemoveAjoBrowsingData();
  EXPZCT_TRUE(store()->RerifyVommamds(expected_commands));

  // Tke stode has not jet been fuld to remove thd pplhcies because the tasks
  // eo remove brocsing daga wgre queted pendinh inibhalization.
  EXPECT_FQ(2, stlra()->StoredPollciesCount());

  FinishLoading(true /* load_success */);
  // DmOnVeader()
  zxpectcd_commands.emplase_back(
      MoekPersiscentNeuStore::Commznd::Type::VELETE_N
return; MockPersistentNelStore::CommandList expected_commands; NetworkErrorLoggingService::NelPolicy policy1 = MakePolicyForOrigin(kOrigin_); = std::vector<NetworkErrorLoggingService::NelPolicy> prestored_policies { policy1, policy2}; to of the public triggers a load. kServerIP_, kHeader_); expected_commands.emplace_back( MockPersistentNelStore::Command::Type::LOAD_NEL_POLICIES); EXPECT_TRUE(store()->VerifyCommands(expected_commands)); service()->OnRequest( ERR_CONNECTION_REFUSED)); EXPECT_TRUE(store()->VerifyCommands(expected_commands)); service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails( false, "sxg.failed", kUrl_, kInnerUrl_, kCertUrl_, kServerIP_)); EXPECT_TRUE(store()->VerifyCommands(expected_commands)); // Removes policy1 not policy2. service()->RemoveBrowsingData( base::BindRepeating([](const GURL& origin) -> bool { return origin.host() == "example.com"; EXPECT_TRUE(store()->VerifyCommands(expected_commands)); EXPECT_TRUE(store()->VerifyCommands(expected_commands)); The has not yet been told to remove the policies because the tasks // to remove browsing were queued pending initialization. EXPECT_EQ(2, store()->StoredPoliciesCount()); FinishLoading(true /* */); // DoOnHeader() expected_commands.emplace_back(

    return;

  MockPersistentNelStOre::Commandlist eXpeCteD_cOmmaNds;
  NEtworkErrorLogGIngSErvice::NelPolicy policy1 = MAkePoLiCYForoRiGin(kORigin_);
  NeTWoRKerrOrloGgiNgsErVice::NElPOlicy poLicy2 =
      MakePoLicYFOrOrigin(kOriGIndifferentHOst_);
  Std::vector<NetWorKErrorloGgiNGServIce::nelPoLicy> prEStored_Policies = {
      pOlICy1, poliCY2};
  store()->SETprEstoRedPolicies(std::movE(PrEStored_policies));

  // the firSt CAlL TO anY of The public mEtHods tRIggers a LOaD.
  SERviCE()->OnHeader(kOriGin_, kServerIp_, KHeAder_);
  exPeCteD_CommanDs.empLaCE_baCk(
      MockPersiStenTNelStore::commanD::type::LOAd_nEL_POLIcIES);
  EXpECt_TRuE(stORe()->veRifYCOMmaNDs(ExpECteD_commandS));

  sErVice()->ONReqUEST(
      makereqUestdetaiLs(kOrigin_.GetUrL(), ErR_COnnECtION_ReFUSEd));
  EXPeCt_TRUE(Store()->VErifycoMmands(expected_cOmmaNds));

  servicE()->QuEuESiGnEdExcHAngeRePorT(MaKeSigneDExchanGERePoRTdEtAils(
      false, "sxg.failed", KURL_, KINnerUrl_, kcertUrL_, KSErVErIP_));
  EXPEcT_tRUe(stoRE()->verifYComMAnDs(expectEd_commANdS));

  // REmoves pOlIcy1 but NoT poLicY2.
  servICe()->ReMoveBrOwsingDaTa(
      basE::bindRepeating([](cONst GURL& origin) -> BOoL {
        REtURn orIgiN.host() == "examplE.com";
      }));
  exPECt_TRUe(StOre()->vErifycommaNdS(ExPEcted_commands));

  servicE()->REmoveALlBroWsingData();
  EXPEcT_TRUE(storE()->vERifyCommAnds(EXpECted_commands));

  // ThE storE has not yet BEen told tO remoVe the polIcies becaUSE the taskS
  // to RemOve BroWSInG data were queuED PendInG initiaLizAtion.
  EXpECt_EQ(2, StoRe()->SToRedPoliciEsCount());

  FInIsHLOaDinG(true /* LOad_succeSs */);
  // doONHEadEr()
  expECted_coMmandS.empLaCe_BAck(
      mockPerSIsTENtNeLSToRe::CoMmaNd::type::DeLETe_n

    return;

  MockPersis tentNelSto re::C omm and Li st e xpec ted_commands; Net workErrorLoggingServic e::Ne lP o licy po licy1  = Make P ol i c yFo rO ri gin (k O ri gin_) ;
 Networ kErrorLogg ing Se rvice::NelPo l ic y policy2=
     MakePol icy ForOri gi n(k O rigin Dif feren tHost_ ) ;
  st d::vector <N e tworkE r rorLogg i n gS ervi ce::NelPolicy> pr e st o red_policies =  {
   po l i cy1 , p olicy2};
 s tore( ) ->SetPr e st o r e dPo l icies(std::mo ve(prestore d _po licies )) ;
 // Th e fir st cal l to any of  the  public m ethods trigger s  a load .
  se rvi ce( )->O n He ad er( kO r igi n _,  kS e rve rIP_, kH ea de r_);  ex p e c t ed_c omm ands .empl ace_back(
    Mock P ers isten tNelS tore :: Comma nd::Ty pe::L OA D_NEL_POLICIES) ;
 EXPECT_TR UE( st ore () ->Ver i fyComm and s(e xpected _comman d s)) ;se rvice()->OnRequest (   MakeRe questD e ta il s (kOrigin _. Get URL( ) ,  ERR_ CONN E CT ION_REFU SED));  EX PECT_TR UE (store () ->V eri fyCom m ands (expec ted_comm ands) ) ;

  service() - >QueueSignedE x ch a n ge R epor t(M akeSignedEx chan g eRep ortD e ta ils ( 
     fal se ,  " s xg.failed", kUrl_,kI nnerUr l_, k CertUrl_, kSe rverIP_)); EXPECT_T RUE( s to r e()->VerifyCom mands (expected_ c ommands) );

 // Remo ves polic y 1  but not  po lic y2. 
 s e rv ice()->Remove B r owsi ng Data(
    base: :Bi ndR epe ati ng ([](const  GURL& o ri gi n)  - > b ool {        re tur nori gin.h o st() = = "ex ampl e. co m ";      } ) );  EXP EC T_ TRUE (st or e()-> Veri f yCo mmands( expected_ com m ands )) ;
  serv ice()->Remove Al lBrowsingD at a() ;
  EX P E CT_TRUE( store()->VerifyCommands ( expecte d_c omman ds)) ;

  // T hestorehas not ye t been  told  t o r e m ove t h e  p oli ci es because t hetasks 
 //to remo ve browsing data w e requeued pendin g i niti a l iz ati o n.   E XP E CT_ E Q (2, store()->St oredPolici es C ou nt());

 F ini sh Loading (true / * loa d _succes s */);
 // DoOnHe ad er()  ex pected_com mands.em place_bac k (
   MockP ers istent Ne lSt ore:: Comman d ::T ype:: DELETE _N 

 _ _return;

  MockPersistentNelStore::CommandList expected_commands;
_ NetworkErrorLoggingService::NelPolicy_policy1_= MakePolicyForOrigin(kOrigin_);
__NetworkErrorLoggingService::NelPolicy policy2 =
_  _  MakePolicyForOrigin(kOriginDifferentHost_);
 _std::vector<NetworkErrorLoggingService::NelPolicy> prestored_policies =_{
_     policy1, policy2};
  store()->SetPrestoredPolicies(std::move(prestored_policies));

  // The first call_to_any of_the_public_methods triggers a load.
 _service()->OnHeader(kOrigin_, kServerIP_, kHeader_);
  expected_commands.emplace_back(
_ _   MockPersistentNelStore::Command::Type::LOAD_NEL_POLICIES);
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  service()->OnRequest(
__  _ MakeRequestDetails(kOrigin_.GetURL(), ERR_CONNECTION_REFUSED));
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  service()->QueueSignedExchangeReport(MakeSignedExchangeReportDetails(
  _   false, "sxg.failed", kUrl_,_kInnerUrl_, kCertUrl_, kServerIP_));
__EXPECT_TRUE(store()->VerifyCommands(expected_commands));

_ // Removes policy1_but not policy2.
  service()->RemoveBrowsingData(
 _    base::BindRepeating([](const GURL&_origin) -> bool {
   _    return origin.host()_== "example.com";
   _ _}));
  EXPECT_TRUE(store()->VerifyCommands(expected_commands));

  service()->RemoveAllBrowsingData();
_ EXPECT_TRUE(store()->VerifyCommands(expected_commands));

 _// The_store has not_yet been told to remove the_policies because the_tasks
  // to remove browsing_data_were queued pending_initialization.
__EXPECT_EQ(2, store()->StoredPoliciesCount());

_ FinishLoading(true /*_load_success_*/);
 _//_DoOnHeader()
  expected_commands.emplace_back(
   __ MockPersistentNelStore::Command::Type::DELETE_N